Title
The const lvalue reference overload of get for subrange does not constrain I to be copyable when N == 0
Status
c++23
Section
[range.subrange]
Submitter
Hewill Kang

Created on 2021-09-08.00:00:00 last changed 13 months ago

Messages

Date: 2021-10-14.09:56:08

Proposed resolution:

This wording is relative to N4892.

  1. Modify [range.subrange] as indicated:

    namespace std::ranges {
      […]
      template<size_t N, class I, class S, subrange_kind K>
        requires ((N < 2== 0 && copyable<I>) || N == 1)
        constexpr auto get(const subrange<I, S, K>& r);
    
      template<size_t N, class I, class S, subrange_kind K>
        requires (N < 2)
        constexpr auto get(subrange<I, S, K>&& r);
    }
    
  2. Modify [range.subrange.access] as indicated:

      […]
      template<size_t N, class I, class S, subrange_kind K>
        requires ((N < 2== 0 && copyable<I>) || N == 1)
        constexpr auto get(const subrange<I, S, K>& r);
      template<size_t N, class I, class S, subrange_kind K>
        requires (N < 2)
        constexpr auto get(subrange<I, S, K>&& r);
    

    -10- Effects: Equivalent to:

    if constexpr (N == 0)
      return r.begin();
    else
      return r.end();
    
Date: 2021-10-14.00:00:00

[ 2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP. ]

Date: 2021-09-15.00:00:00

[ 2021-09-20; Reflector poll ]

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

Date: 2021-09-15.00:00:00

[ 2021-09-20; Reflector poll ]

Set priority to 3 after reflector poll.

Date: 2021-09-08.00:00:00

The const lvalue reference overload of get used for subrange only constraint that N < 2, this will cause the "discards qualifiers" error inside the function body when applying get to the lvalue subrange that stores a non-copyable iterator since its begin() is non-const qualified, we probably need to add a constraint for it.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2021-10-14 09:56:08adminsetmessages: + msg12140
2021-10-14 09:56:08adminsetstatus: voting -> wp
2021-09-29 12:57:28adminsetstatus: ready -> voting
2021-09-20 13:52:41adminsetmessages: + msg12060
2021-09-20 13:52:41adminsetstatus: new -> ready
2021-09-20 11:22:03adminsetmessages: + msg12054
2021-09-11 13:51:19adminsetmessages: + msg12032
2021-09-08 00:00:00admincreate