Merge "std::string_view is no longer experimental."
am: c8022a3efc
Change-Id: I75fa251cb6a959e7dfd32524b8d0ffcf839c3dc4
diff --git a/liblog/event_tag_map.cpp b/liblog/event_tag_map.cpp
index 83064fd..2e2bf87 100644
--- a/liblog/event_tag_map.cpp
+++ b/liblog/event_tag_map.cpp
@@ -25,9 +25,9 @@
#include <string.h>
#include <sys/mman.h>
-#include <experimental/string_view>
#include <functional>
#include <string>
+#include <string_view>
#include <unordered_map>
#include <log/event_tag_map.h>
@@ -44,10 +44,10 @@
class MapString {
private:
const std::string* alloc; // HAS-AN
- const std::experimental::string_view str; // HAS-A
+ const std::string_view str; // HAS-A
public:
- operator const std::experimental::string_view() const {
+ operator const std::string_view() const {
return str;
}
@@ -92,8 +92,7 @@
: public std::unary_function<const MapString&, size_t> {
size_t operator()(const MapString& __t) const noexcept {
if (!__t.length()) return 0;
- return std::hash<std::experimental::string_view>()(
- std::experimental::string_view(__t));
+ return std::hash<std::string_view>()(std::string_view(__t));
}
};
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
index 8808aac..ac3cf9a 100644
--- a/logd/LogStatistics.h
+++ b/logd/LogStatistics.h
@@ -25,9 +25,9 @@
#include <sys/types.h>
#include <algorithm> // std::max
-#include <experimental/string_view>
#include <memory>
-#include <string> // std::string
+#include <string>
+#include <string_view>
#include <unordered_map>
#include <android-base/stringprintf.h>
@@ -495,7 +495,7 @@
struct TagNameKey {
std::string* alloc;
- std::experimental::string_view name; // Saves space if const char*
+ std::string_view name; // Saves space if const char*
explicit TagNameKey(const LogBufferElement* element)
: alloc(nullptr), name("", strlen("")) {
@@ -504,31 +504,31 @@
if (tag) {
const char* cp = android::tagToName(tag);
if (cp) {
- name = std::experimental::string_view(cp, strlen(cp));
+ name = std::string_view(cp, strlen(cp));
return;
}
}
alloc = new std::string(
android::base::StringPrintf("[%" PRIu32 "]", tag));
if (!alloc) return;
- name = std::experimental::string_view(alloc->c_str(), alloc->size());
+ name = std::string_view(alloc->c_str(), alloc->size());
return;
}
const char* msg = element->getMsg();
if (!msg) {
- name = std::experimental::string_view("chatty", strlen("chatty"));
+ name = std::string_view("chatty", strlen("chatty"));
return;
}
++msg;
unsigned short len = element->getMsgLen();
len = (len <= 1) ? 0 : strnlen(msg, len - 1);
if (!len) {
- name = std::experimental::string_view("<NULL>", strlen("<NULL>"));
+ name = std::string_view("<NULL>", strlen("<NULL>"));
return;
}
alloc = new std::string(msg, len);
if (!alloc) return;
- name = std::experimental::string_view(alloc->c_str(), alloc->size());
+ name = std::string_view(alloc->c_str(), alloc->size());
}
explicit TagNameKey(TagNameKey&& rval)
@@ -545,7 +545,7 @@
if (alloc) delete alloc;
}
- operator const std::experimental::string_view() const {
+ operator const std::string_view() const {
return name;
}
@@ -576,8 +576,7 @@
: public std::unary_function<const TagNameKey&, size_t> {
size_t operator()(const TagNameKey& __t) const noexcept {
if (!__t.length()) return 0;
- return std::hash<std::experimental::string_view>()(
- std::experimental::string_view(__t));
+ return std::hash<std::string_view>()(std::string_view(__t));
}
};