This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4002. The definition of iota_view::iterator::iterator_concept should be improved

Section: [range.iota.iterator] Status: New Submitter: Hewill Kang Opened: 2023-10-27 Last modified: 2023-11-07

Priority: 3

View other active issues in [range.iota.iterator].

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

View all issues with New status.


When W models incrementable, the iota_view iterator will be a forward_iterator, which accidentally makes iota_view<istream_iterator<int>> satisfies forward_range, which is obviously incorrect.

Since iterator types are well within the domain of W, it seems more appropriate and accurate to define the iterator_concept through the iterator concept in this case.

[2023-11-07; Reflector poll]

Set priority to 3 after reflector poll. "This would change the iterator concept for types which model advanceable but do not model random_access_iterator. A type with += and -= and operator* will currently get random_access_iterator_tag but this proposed resolution would change it to bidirectional_iterator_tag." "If we want to handle this case (and not leave it as IFNDR - the type satisfies-but-not-models incrementable) then we need to account for it everywhere we are currently using incrementable (and possibly equality_comparable?), and not just in the concept."

Proposed resolution:

This wording is relative to N4964.

  1. Modify [range.iota.iterator] as indicated:

    [Drafting note: When W only models input_or_output_iterator, it implies that its pre- and post-increment are not equality-preserving, so iterator_concept should be input_iterator_tag.]

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

    1. (?.?) — If W models input_or_output_iterator, then

      1. (?.?) — if W models random_access_iterator, then iterator_concept is random_access_iterator_tag;

      2. (?.?) — otherwise, if W models bidirectional_iterator, then iterator_concept is bidirectional_iterator_tag;

      3. (?.?) — otherwise, if W models forward_iterator, then iterator_concept is forward_iterator_tag;

      4. (?.?) — otherwise, iterator_concept is input_iterator_tag.

    2. (1.1) — Otherwise, iIf W models advanceable, then iterator_concept is random_access_iterator_tag.

    3. (1.2) — Otherwise, if W models decrementable, then iterator_concept is bidirectional_iterator_tag.

    4. (1.3) — Otherwise, if W models incrementable, then iterator_concept is forward_iterator_tag.

    5. (1.4) — Otherwise, iterator_concept is input_iterator_tag.