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.
_LIBCPP_DEBUG is never 2, see libcxx/include/__config:893:
Yes, it is terribly confusing. It was even worse before I documented it (lol). I think you want to use _LIBCPP_DEBUG_LEVEL == 2 instead.