summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sam McCall <sammccall@google.com>2023-12-15 02:31:21 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-12-15 02:32:11 -0800
commit27478af36914f18867ea32cb42db00dba15fffcd (patch)
tree7a985d8adeb27614fe6e4de03c7bb93f1e945927
parenta7e3dafd035024803b80676ab8ed02b4acb9b111 (diff)
Remove nullability from Span::{pointer,iterator}
These are in some sense correct (begin()/end() can be null for empty spans), but don't capture the critical contract that begin() is only null when end() is. This leads to foreach loops over spans being considered unsafe. Long-term we may want to express such constraints somehow, but for now giving these pointers unknown nullability is the best we can do. PiperOrigin-RevId: 591191038 Change-Id: I1f02e068a445c0ca5996a9212477b64393ef4161
-rw-r--r--absl/types/span.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/absl/types/span.h b/absl/types/span.h
index 7d1d0166..88cd7595 100644
--- a/absl/types/span.h
+++ b/absl/types/span.h
@@ -173,8 +173,10 @@ class Span {
public:
using element_type = T;
using value_type = absl::remove_cv_t<T>;
- using pointer = absl::Nullable<T*>;
- using const_pointer = absl::Nullable<const T*>;
+ // TODO(b/316099902) - pointer should be Nullable<T*>, but this makes it hard
+ // to recognize foreach loops as safe.
+ using pointer = T*;
+ using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
using iterator = pointer;