Skip to content

subrange: must end be reachable from begin? #597

Description

@ericniebler

Is it kosher to construct a subrange for which end is not reachable from begin? Say, if begin is reachable from end instead? And size() returns a negative number?

Probably not. If that is the case, we should require that [begin,end) denotes a valid range.

Proposed Resolution

Change [range.subrange.ctor] as follows:

 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).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions