Title
possibly-const-range is overconstrained
Status
nad
Section
[ranges.syn]
Submitter
Hewill Kang

Created on 2022-09-08.00:00:00 last changed 25 months ago

Messages

Date: 2022-11-30.17:59:24

Proposed resolution:

This wording is relative to n4917.

  1. Modify [ranges.syn] as indicated:

    #include <compare>              // see [compare.syn]
    #include <initializer_list>     // see [initializer.list.syn]
    #include <iterator>             // see [iterator.synopsis]
    
    namespace std::ranges {
      […]
    
      // [range.as.const], as const view
      template<input_range R>
        constexpr auto& possibly-const-range(R& r) {          // exposition only
          if constexpr (constant_range<const R> && !constant_range<R>) {
            return const_cast<const R&>(r);
          } else {
            return r;
          }
        } 
      
      […]
    }
    
Date: 2022-11-30.00:00:00

[ 2022-11-30 LWG telecon. Status changed: Tentatively NAD → NAD. ]

Date: 2022-09-15.00:00:00

[ 2022-09-23; Reflector poll ]

Tentatively NAD. "const output ranges don’t seem to be useful."

Date: 2022-09-08.00:00:00

Due to the possibly-const-range constraint that the template parameter R must model input_range, this makes the ranges::cend that tries using it for meaningful const casting never be applied to an output_range, even though const_sentinel does not require the template parameter S to model input_iterator.

This is unnecessary, we should relax its constraint.

History
Date User Action Args
2022-11-30 17:59:24adminsetmessages: + msg13140
2022-09-23 15:43:32adminsetmessages: + msg12791
2022-09-23 15:43:32adminsetstatus: new -> nad
2022-09-08 06:56:08adminsetmessages: + msg12750
2022-09-08 00:00:00admincreate