Title
const_sentinel should be constrained
Status
c++23
Section
[iterator.synopsis][const.iterators.alias]
Submitter
Hewill Kang

Created on 2022-09-09.00:00:00 last changed 5 months ago

Messages

Date: 2022-11-17.00:42:33

Proposed resolution:

This wording is relative to n4917.

  1. Modify [iterator.synopsis], header <iterator> synopsis, as indicated:

    #include <compare>              // see [compare.syn]
    #include <concepts>             // see [concepts.syn]
    
    namespace std {
      […]
      
      // [const.iterators], constant iterators and sentinels
      // [const.iterators.alias], alias templates
      […]
      template<input_iterator I>
        using const_iterator = see below;                                               // freestanding
      template<semiregularclass S>
        using const_sentinel = see below;                                               // freestanding
    
      […]
      template<input_iterator I>
        constexpr const_iterator<I> make_const_iterator(I it) { return it; }            // freestanding
    
      template<semiregularclass S>
        constexpr const_sentinel<S> make_const_sentinel(S s) { return s; }              // freestanding
      […]
    }
    
  2. Modify [const.iterators.alias] as indicated:

    template<semiregularclass S>
      using const_sentinel = see below;
    

    -2- Result: If S models input_iterator, const_iterator<S>. Otherwise, S.

Date: 2022-11-12.00:00:00

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

Date: 2022-09-15.00:00:00

[ 2022-09-23; Reflector poll ]

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

Date: 2022-09-09.00:00:00

The current standard does not have any constraints on const_sentinel template parameters, which makes it possible to pass almost any type of object to make_const_sentinel. It would be more appropriate to constrain the type to meet the minimum requirements of the sentinel type such as semiregular as move_sentinel does.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2022-11-17 00:42:33adminsetmessages: + msg13071
2022-11-17 00:42:33adminsetstatus: voting -> wp
2022-11-08 03:46:49adminsetstatus: ready -> voting
2022-09-23 15:43:32adminsetmessages: + msg12787
2022-09-23 15:43:32adminsetstatus: new -> ready
2022-09-09 00:00:00admincreate
2022-09-03 18:11:40adminsetmessages: + msg12739