diff options
author | Abseil Team <absl-team@google.com> | 2024-04-09 09:42:18 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-04-09 09:42:59 -0700 |
commit | 8f9e5f0203c8a708c71f4498bf59355d1d7bbf87 (patch) | |
tree | 7b23c4fa4a1b55ff9d09e7ce05e322592ad031d7 /absl/strings | |
parent | 6c3982787d3e1e288ee6a25ec4a1d7ee9d1c571e (diff) |
Restore string_view detection check
PiperOrigin-RevId: 623195368
Change-Id: Iadb9bdedee4d9b5ced4fff9e6316ee63f9a89ea5
Diffstat (limited to 'absl/strings')
-rw-r--r-- | absl/strings/string_view.h | 1 | ||||
-rw-r--r-- | absl/strings/string_view_test.cc | 8 |
2 files changed, 9 insertions, 0 deletions
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 1c73943e..e978fc3f 100644 --- a/absl/strings/string_view_test.cc +++ b/absl/strings/string_view_test.cc @@ -47,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 { |