3555. {transform,elements}_view::iterator::iterator_concept should consider const-qualification of the underlying range

Section: 25.7.9.3 [range.transform.iterator], 25.7.23.3 [range.elements.iterator] Status: C++23 Submitter: Tim Song Opened: 2021-05-23 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [range.transform.iterator].

View all issues with C++23 status.

Discussion:

transform_view::iterator<true>::iterator_concept and elements_view::iterator<true>::iterator_concept (i.e., the const versions) are currently specified as looking at the properties of V (i.e., the underlying view without const), while the actual iterator operations are all correctly specified as using Base (which includes the const). iterator_concept should do so too.

The proposed resolution has been implemented and tested on top of libstdc++.

[2021-05-26; Reflector poll]

Set status to Tentatively Ready after six 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 25.7.9.3 [range.transform.iterator] as indicated:

    -1- iterator::iterator_concept is defined as follows:

    1. (1.1) — If VBase models random_access_range, then iterator_concept denotes random_access_iterator_tag.

    2. (1.2) — Otherwise, if VBase models bidirectional_range, then iterator_concept denotes bidirectional_iterator_tag.

    3. (1.3) — Otherwise, if VBase models forward_range, then iterator_concept denotes forward_iterator_tag.

    4. (1.4) — Otherwise, iterator_concept denotes input_iterator_tag.

  2. Modify 25.7.23.3 [range.elements.iterator] as indicated:

    -1- The member typedef-name iterator_concept is defined as follows:

    1. (1.1) — If VBase models random_access_range, then iterator_concept denotes random_access_iterator_tag.

    2. (1.2) — Otherwise, if VBase models bidirectional_range, then iterator_concept denotes bidirectional_iterator_tag.

    3. (1.3) — Otherwise, if VBase models forward_range, then iterator_concept denotes forward_iterator_tag.

    4. (1.4) — Otherwise, iterator_concept denotes input_iterator_tag.