This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.

3770. const_sentinel_t is missing

Section: 26.2 [ranges.syn] Status: C++23 Submitter: Hewill Kang Opened: 2022-09-05 Last modified: 2023-11-22

Priority: 3

View other active issues in [ranges.syn].

View all other issues in [ranges.syn].

View all issues with C++23 status.

Discussion:

The type alias pair const_iterator and const_sentinel and the factory function pair make_const_iterator and make_const_sentinel are defined in <iterator>, however, only const_iterator_t exists in <ranges>, which lacks const_sentinel_t, we should add it to ensure consistency.

The proposed resolution also lifts the type constraint of const_iterator_t to input_range to make it consistent with const_iterator, which already requires that its template parameter must model input_iterator.

[2022-09-23; Reflector poll]

Set priority to 3 after reflector poll.

Comment from a reviewer:

"I don't see why we should redundantly constrain const_iterator_t with input_range; it's not as if we can make it more ill-formed or more SFINAE-friendly than it is now."

Previous resolution [SUPERSEDED]:

This wording is relative to N4917.

  1. Modify 26.2 [ranges.syn], header <ranges> synopsis, as indicated:

    #include <compare>              // see 17.11.1 [compare.syn]
    #include <initializer_list>     // see 17.10.2 [initializer.list.syn]
    #include <iterator>             // see 25.2 [iterator.synopsis]
    
    namespace std::ranges {
      […]
      template<class T>
        using iterator_t = decltype(ranges::begin(declval<T&>()));                      // freestanding
      template<range R>
        using sentinel_t = decltype(ranges::end(declval<R&>()));                        // freestanding
      template<input_range R>
        using const_iterator_t = const_iterator<iterator_t<R>>;                         // freestanding
      template<range R>
        using const_sentinel_t = const_sentinel<sentinel_t<R>>;                         // freestanding
      […]
    }
    

[2022-09-25; Daniel and Hewill provide alternative wording]

The alternative solution solely adds the suggested const_sentinel_t alias template and doesn't touch the const_iterator_t constraints.

[2022-10-12; Reflector poll]

Set status to "Tentatively Ready" after seven votes in favour.

[2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4917.

  1. Modify 26.2 [ranges.syn], header <ranges> synopsis, as indicated:

    #include <compare>              // see 17.11.1 [compare.syn]
    #include <initializer_list>     // see 17.10.2 [initializer.list.syn]
    #include <iterator>             // see 25.2 [iterator.synopsis]
    
    namespace std::ranges {
      […]
      template<class T>
        using iterator_t = decltype(ranges::begin(declval<T&>()));                      // freestanding
      template<range R>
        using sentinel_t = decltype(ranges::end(declval<R&>()));                        // freestanding
      template<range R>
        using const_iterator_t = const_iterator<iterator_t<R>>;                         // freestanding
      template<range R>
        using const_sentinel_t = const_sentinel<sentinel_t<R>>;                         // freestanding
      […]
    }