This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
counted_iterators
refer to the same sequence isn't quite rightSection: 24.5.7.1 [counted.iterator] Status: C++23 Submitter: Tim Song Opened: 2021-04-21 Last modified: 2023-11-22
Priority: Not Prioritized
View all other issues in [counted.iterator].
View all issues with C++23 status.
Discussion:
24.5.7.1 [counted.iterator]/3 says:
Two values
i1
andi2
of typescounted_iterator<I1>
andcounted_iterator<I2>
refer to elements of the same sequence if and only ifnext(i1.base(), i1.count())
andnext(i2.base(), i2.count())
refer to the same (possibly past-the-end) element.
However, some users of counted_iterator
(such as take_view
) don't guarantee that
there are count()
elements past base()
. It seems that we need to rephrase this
definition to account for such uses.
[2021-05-10; Reflector poll]
Set status to Tentatively Ready after five votes in favour during reflector poll.
[2021-06-07 Approved at June 2021 virtual plenary. Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4885.
Modify 24.5.7.1 [counted.iterator] as indicated:
-3- Two values
i1
andi2
of typescounted_iterator<I1>
andcounted_iterator<I2>
refer to elements of the same sequence if and only if there exists some integern
such thatnext(i1.base(), i1.count() + n)
andnext(i2.base(), i2.count() + n)
refer to the same (possibly past-the-end) element.