-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
LWG issue neededA wording defect that should be submitted to LWG as a new issueA wording defect that should be submitted to LWG as a new issue
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
LWG issue neededA wording defect that should be submitted to LWG as a new issueA wording defect that should be submitted to LWG as a new issue