Title
cartesian_product_view::iterator's default constructor is overconstrained
Status
c++23
Section
[range.cartesian.iterator]
Submitter
Hewill Kang

Created on 2023-01-06.00:00:00 last changed 13 months ago

Messages

Date: 2023-02-13.10:17:57

Proposed resolution:

This wording is relative to N4917.

  1. Modify [ranges.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:
        […]
        iterator() requires forward_range<maybe-const<Const, First>> = default;
        […]
      private:
        using Parent = maybe-const<Const, cartesian_product_view>;          // exposition only
        Parent* parent_ = nullptr;                                          // exposition only
        tuple<iterator_t<maybe-const<Const, First>>,
          iterator_t<maybe-const<Const, Vs>>...> current_;                  // exposition only
        […]
      };
    }
    
Date: 2023-02-13.00:00:00

[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting → WP. ]

Date: 2023-02-15.00:00:00

[ 2023-02-01; Reflector poll ]

Set status to Tentatively Ready after nine votes in favour during reflector poll.

Date: 2023-01-06.00:00:00

Currently, cartesian_product_view::iterator only provides the default constructor when the first range models forward_range, which seems too restrictive since several input iterators like istream_iterator are still default-constructible.

It would be more appropriate to constrain the default constructor only by whether the underlying iterator satisfies default_initializable, as most other range adaptors do. Since cartesian_product_view::iterator contains a tuple member that already has a constrained default constructor, the proposed resolution simply removes the constraint.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2023-02-13 10:17:57adminsetmessages: + msg13369
2023-02-13 10:17:57adminsetstatus: voting -> wp
2023-02-06 15:33:48adminsetstatus: ready -> voting
2023-02-01 20:33:52adminsetmessages: + msg13243
2023-02-01 20:33:52adminsetstatus: new -> ready
2023-01-06 16:24:01adminsetmessages: + msg13185
2023-01-06 00:00:00admincreate