summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--absl/strings/BUILD.bazel1
-rw-r--r--absl/strings/CMakeLists.txt1
-rw-r--r--absl/strings/string_view.h1
-rw-r--r--absl/strings/string_view_test.cc9
4 files changed, 12 insertions, 0 deletions
diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel
index 8b307832..d93a78a9 100644
--- a/absl/strings/BUILD.bazel
+++ b/absl/strings/BUILD.bazel
@@ -359,6 +359,7 @@ cc_test(
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:dynamic_annotations",
+ "//absl/meta:type_traits",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
diff --git a/absl/strings/CMakeLists.txt b/absl/strings/CMakeLists.txt
index 9258e553..53e85188 100644
--- a/absl/strings/CMakeLists.txt
+++ b/absl/strings/CMakeLists.txt
@@ -274,6 +274,7 @@ absl_cc_test(
absl::config
absl::core_headers
absl::dynamic_annotations
+ absl::type_traits
GTest::gmock_main
)
diff --git a/absl/strings/string_view.h b/absl/strings/string_view.h
index b393c6fc..b1fb7a10 100644
--- a/absl/strings/string_view.h
+++ b/absl/strings/string_view.h
@@ -173,6 +173,7 @@ class string_view {
using reverse_iterator = const_reverse_iterator;
using size_type = size_t;
using difference_type = std::ptrdiff_t;
+ using absl_internal_is_view = std::true_type;
static constexpr size_type npos = static_cast<size_type>(-1);
diff --git a/absl/strings/string_view_test.cc b/absl/strings/string_view_test.cc
index 251f1842..e978fc3f 100644
--- a/absl/strings/string_view_test.cc
+++ b/absl/strings/string_view_test.cc
@@ -32,6 +32,7 @@
#include "gtest/gtest.h"
#include "absl/base/config.h"
+#include "absl/meta/type_traits.h"
#if defined(ABSL_HAVE_STD_STRING_VIEW) || defined(__ANDROID__)
// We don't control the death messaging when using std::string_view.
@@ -46,6 +47,14 @@
namespace {
+static_assert(!absl::type_traits_internal::IsOwner<absl::string_view>::value &&
+ absl::type_traits_internal::IsView<absl::string_view>::value,
+ "string_view is a view, not an owner");
+
+static_assert(absl::type_traits_internal::IsLifetimeBoundAssignment<
+ absl::string_view, std::string>::value,
+ "lifetimebound assignment not detected");
+
// A minimal allocator that uses malloc().
template <typename T>
struct Mallocator {