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.

4116. enumerate_view::iterator and cartesian_product_view::iterator should not always provide iterator_category

Section: 25.7.24.3 [range.enumerate.iterator], 25.7.33.3 [range.cartesian.iterator] Status: New Submitter: Hewill Kang Opened: 2024-07-07 Last modified: 2024-07-07

Priority: Not Prioritized

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

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

View all issues with New status.

Discussion:

These two iterators do not support *r++ for non-forward iterators, so we should not provide iterator_category as they are not C++17 iterators.

Proposed resolution:

This wording is relative to N4981.

  1. Modify 25.7.24.3 [range.enumerate.iterator] as indicated:

    namespace std::ranges {
      template<view V>
        requires range-with-movable-references<V>
      template<bool Const>
      class enumerate_view<V>::iterator {
        using Base = maybe-const<Const, V>;                         // exposition only
    
      public:
        using iterator_category = input_iterator_tag;      // present only if Base
                                                           // models forward_range
        using iterator_concept = see below;
        […]
      };
    }
    
  2. Modify 25.7.33.3 [range.cartesian.iterator] as indicated:

    namespace std::ranges {
      template<input_range First, forward_range... Vs>
        requires (view<First> && ... && view<Vs>)
      template<bool Const>
      class cartesian_product_view<First, Vs...>::iterator {
      public:
        using iterator_category = input_iterator_tag;      // present only if maybe-const<Const, First>
                                                           // models forward_range
        using iterator_concept  = see below;
        […]
      };
    }