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.

3543. Definition of when counted_iterators refer to the same sequence isn't quite right

Section: 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 and i2 of types counted_iterator<I1> and counted_iterator<I2> refer to elements of the same sequence if and only if next(i1.base(), i1.count()) and next(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.

  1. Modify 24.5.7.1 [counted.iterator] as indicated:

    -3- Two values i1 and i2 of types counted_iterator<I1> and counted_iterator<I2> refer to elements of the same sequence if and only if there exists some integer n such that next(i1.base(), i1.count() + n) and next(i2.base(), i2.count() + n) refer to the same (possibly past-the-end) element.