Commit 27478af3 by Sam McCall Committed by Copybara-Service

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
parent a7e3dafd
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment