aboutsummaryrefslogtreecommitdiff
path: root/absl/types
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2024-04-02 07:40:17 -0700
committerCopybara-Service <copybara-worker@google.com>2024-04-02 07:41:11 -0700
commitc02bb5f6dae73df83abc0d960ccf5cf3ab00f24c (patch)
tree5e4e73f4db1b1ff228f3d5d90e2ebc081a79e329 /absl/types
parentf5227676b03b0d7c9fea931f979e336d613635eb (diff)
downloadabseil-c02bb5f6dae73df83abc0d960ccf5cf3ab00f24c.tar.gz
abseil-c02bb5f6dae73df83abc0d960ccf5cf3ab00f24c.tar.bz2
abseil-c02bb5f6dae73df83abc0d960ccf5cf3ab00f24c.zip
Add internal traits to absl::Span for lifetimebound detection
PiperOrigin-RevId: 621169753 Change-Id: Ib6d7b248e14f29f1f91c24b8e1cf9703962b0e36
Diffstat (limited to 'absl/types')
-rw-r--r--absl/types/BUILD.bazel1
-rw-r--r--absl/types/CMakeLists.txt1
-rw-r--r--absl/types/span.h1
-rw-r--r--absl/types/span_test.cc5
4 files changed, 8 insertions, 0 deletions
diff --git a/absl/types/BUILD.bazel b/absl/types/BUILD.bazel
index ce8f605b..a86e2c13 100644
--- a/absl/types/BUILD.bazel
+++ b/absl/types/BUILD.bazel
@@ -138,6 +138,7 @@ cc_test(
"//absl/container:fixed_array",
"//absl/container:inlined_vector",
"//absl/hash:hash_testing",
+ "//absl/meta:type_traits",
"//absl/strings",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
diff --git a/absl/types/CMakeLists.txt b/absl/types/CMakeLists.txt
index 92b4ae49..fed532fc 100644
--- a/absl/types/CMakeLists.txt
+++ b/absl/types/CMakeLists.txt
@@ -138,6 +138,7 @@ absl_cc_test(
absl::inlined_vector
absl::hash_testing
absl::strings
+ absl::type_traits
GTest::gmock_main
)
diff --git a/absl/types/span.h b/absl/types/span.h
index c183aa88..560e569b 100644
--- a/absl/types/span.h
+++ b/absl/types/span.h
@@ -185,6 +185,7 @@ class Span {
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using size_type = size_t;
using difference_type = ptrdiff_t;
+ using absl_internal_is_view = std::true_type;
static const size_type npos = ~(size_type(0));
diff --git a/absl/types/span_test.cc b/absl/types/span_test.cc
index 29e8681f..e24144dd 100644
--- a/absl/types/span_test.cc
+++ b/absl/types/span_test.cc
@@ -31,10 +31,15 @@
#include "absl/container/fixed_array.h"
#include "absl/container/inlined_vector.h"
#include "absl/hash/hash_testing.h"
+#include "absl/meta/type_traits.h"
#include "absl/strings/str_cat.h"
namespace {
+static_assert(!absl::type_traits_internal::IsOwner<absl::Span<int>>::value &&
+ absl::type_traits_internal::IsView<absl::Span<int>>::value,
+ "Span is a view, not an owner");
+
MATCHER_P(DataIs, data,
absl::StrCat("data() ", negation ? "isn't " : "is ",
testing::PrintToString(data))) {