A span has no idea what container (if any) "owns" its iterators, nor under what circumstances they might become invalidated. This fixes the following libcxx tests under `-D_LIBCPP_DEBUG=1`: - libcxx/test/std/containers/views/span.cons/deduct.pass.cpp - libcxx/test/std/containers/views/span.iterators/begin.pass.cpp - libcxx/test/std/containers/views/span.iterators/end.pass.cpp - libcxx/test/std/containers/views/span.iterators/rbegin.pass.cpp - libcxx/test/std/containers/views/span.iterators/rend.pass.cpp - libcxx/test/std/containers/views/span.sub/first.pass.cpp - libcxx/test/std/containers/views/span.sub/last.pass.cpp - libcxx/test/std/containers/views/span.sub/subspan.pass.cpp
It does occur to me that we could probably come up with a strategy for string_view and span to do debug iterators, where you could form an association of a string_view object with a C object, and the string_view's iterators would be sort of "transitively" associated with that C; and this association would be formed whenever you (1) converted a string directly to a string_view or (2) constructed a string_view from a pair of C::iterator (for C=string or vector). However, this idea is clearly beyond the scope of this PR, and I'm not aware that anyone is asking for it to exist, either.
@miscco asks "Are there ABI concerns for span?" Well, in order to break, they'd have to be passing a span<T>::iterator across an ABI boundary. (Just passing a const span<T>& would be fine.) And span is new in C++20, which we don't claim to implement yet. So I think now is the perfect time to fix it. :)
Anyway, we kinda don't have a choice, right? :) The existing code simply fails to compile in _LIBCPP_DEBUG=1 mode, and I think we need it to compile.