Title
The definition of iota_view::iterator::iterator_concept should be improved
Status
new
Section
[range.iota.iterator]
Submitter
Hewill Kang

Created on 2023-10-27.00:00:00 last changed 13 months ago

Messages

Date: 2023-11-07.18:35:04

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.

Date: 2023-11-15.00:00:00

[ 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."

Date: 2023-10-27.00:00:00

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.

History
Date User Action Args
2023-11-07 18:35:04adminsetmessages: + msg13822
2023-10-28 13:17:11adminsetmessages: + msg13775
2023-10-27 00:00:00admincreate