Describe the bug
Checked iterators controlled by _ITERATOR_DEBUG_LEVEL provide some safe guarantee, but these assertions became more and more intolerant for programming in normal styles.
Command-line test case
std::array<std::byte, 10> a{};
std::span<std::byte> s1 = a;
std::span<std::byte> s2 = s1.subspan(1);
std::cout << s2.begin() - s1.begin(); // assertion failed while _ITERATOR_DEBUG_LEVEL >= 1
Expected behavior
Both these two span s1 and s2 came from a, hence they share the same underlying sequence.
I think this design makes iterators of the same type pointing to the same element not equivalent. (may be an LWG issue?)
From a programmer’s point of view, the code snippet above is a common requirement, especially when parsing certain data.
STL version
Microsoft Visual Studio Community 2019
Version 16.7.7
Describe the bug
Checked iterators controlled by
_ITERATOR_DEBUG_LEVELprovide some safe guarantee, but these assertions became more and more intolerant for programming in normal styles.Command-line test case
Expected behavior
Both these two span
s1ands2came froma, hence they share the same underlying sequence.I think this design makes iterators of the same type pointing to the same element not equivalent. (may be an LWG issue?)
From a programmer’s point of view, the code snippet above is a common requirement, especially when parsing certain data.
STL version