Title
subrange should always model Range
Status
c++20
Section
[range.subrange.ctor]
Submitter
Casey Carter

Created on 2018-12-21.00:00:00 last changed 38 months ago

Messages

Date: 2019-01-20.16:20:00

Proposed resolution:

This wording is relative to N4791.

  1. Change [range.subrange.ctor] as indicated:

    constexpr subrange(I i, S s) requires (!StoreSize);
    

    -?- Expects: [i, s) is a valid range.

    -1- Effects: Initializes begin_ with i and end_ with s.

    constexpr subrange(I i, S s, iter_difference_t<I> n)
      requires (K == subrange_kind::sized);
    

    -2- Expects: [i, s) is a valid range, and n == ranges::distance(i, s).

Date: 2019-01-20.00:00:00

[ 2019-01-20 Reflector prioritization ]

Set Priority to 0 and status to Tentatively Ready

Date: 2018-12-21.00:00:00

The constructors of subrange place no requirements on the iterator and sentinel values from which a subrange is constructed. They allow constructions like subrange{myvec.end(), myvec.begin()} in which the resulting subrange isn't in the domain of the Range concept which requires that "[ranges::begin(r), ranges::end(r)) denotes a range" ([range.range]/3.1). We should forbid the construction of abominable values like this to enforce the useful semantic that values of subrange are always in the domain of Range.

(From ericniebler/stl2#597.)

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2019-02-26 17:40:23adminsetstatus: voting -> wp
2019-01-21 04:50:04adminsetstatus: ready -> voting
2019-01-20 16:20:00adminsetmessages: + msg10292
2019-01-20 16:20:00adminsetstatus: new -> ready
2018-12-21 18:25:19adminsetmessages: + msg10270
2018-12-21 00:00:00admincreate