Title
iota_view::iterator has the wrong iterator_category
Status
c++20
Section
[range.iota.iterator]
Submitter
Eric Niebler

Created on 2019-09-13.00:00:00 last changed 38 months ago

Messages

Date: 2019-10-19.11:34:54

Proposed resolution:

This wording is relative to N4830.

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

    namespace std::ranges {
      template<class W, class Bound>
      struct iota_view<W, Bound>::iterator {
      private:
        […]
      public:
        using iterator_conceptategory = see below;
        using iterator_category = input_iterator_tag;
        using value_type = W;
        using difference_type = IOTA-DIFF-T(W);
        […]
      };
      […]
    }
    

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

    1. (1.1) — If W models advanceable, then iterator_conceptategory is random_access_iterator_tag.

    2. (1.2) — Otherwise, if W models decrementable, then iterator_conceptategory is bidirectional_iterator_tag.

    3. (1.3) — Otherwise, if W models incrementable, then iterator_conceptategory is forward_iterator_tag.

    4. (1.4) — Otherwise, iterator_conceptategory is input_iterator_tag.

Date: 2019-10-19.00:00:00

[ 2019-10-19 Issue Prioritization ]

Status to Tentatively Ready and priority to 0 after eight positive votes on the reflector.

Date: 2019-09-13.00:00:00

In the old way of looking at the world, forward iterators need to return real references. Since dereferencing iota_view's iterators returns by value, it cannot be a C++17 forward iterator. (It can, however, be a C++20 forward_iterator.) However, iota_view's iterator has an iterator_category that (sometimes) falsely claims that it is forward or better (depending on the properties of the weakly_incrementable type it wraps).

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: voting -> wp
2020-01-17 04:54:50adminsetstatus: ready -> voting
2019-10-19 11:34:54adminsetmessages: + msg10703
2019-10-19 11:34:54adminsetstatus: new -> ready
2019-09-18 17:59:07adminsetmessages: + msg10653
2019-09-13 00:00:00admincreate