Title
ranges::cbegin/ranges::cend, (and maybe ranges::crbegin/ranges::crend) are under-specified to allow rvalue-arrays
Status
nad
Section
[range.access.cbegin][range.access.cend]
Submitter
Christopher Di Bella

Created on 2019-11-06.00:00:00 last changed 51 months ago

Messages

Date: 2020-02-13.12:32:11

Proposed resolution:

This wording is relative to N4835.

  1. Change [range.access.cbegin] as indicated:

    -1- The name ranges::cbegin denotes a customization point object ([customization.point.object]). If tThe expression ranges::cbegin(E) for some subexpression E of type T is well-formed, then the expression ranges::cbegin(E) is expression-equivalent to:

    1. (1.1) — ranges::begin(static_cast<const T&>(E)) if E is an lvalue.

    2. (1.2) — Otherwise, ranges::begin(static_cast<const T&&>(E)).

  2. Change [range.access.cend] as indicated:

    -1- The name ranges::cend denotes a customization point object ([customization.point.object]). If tThe expression ranges::cend(E) for some subexpression E of type T is well-formed, then the expression ranges::cend(E) is expression-equivalent to:

    1. (1.1) — ranges::end(static_cast<const T&>(E)) if E is an lvalue.

    2. (1.2) — Otherwise, ranges::end(static_cast<const T&&>(E)).

Date: 2020-02-13.12:32:11

[ 2020-02 Status to NAD on Thursday morning in Prague. ]

Date: 2019-11-06.00:00:00

The following should be ill-formed, but is not, likely due to decay-to-pointer or reference collapsing.

double x[321];
ranges::cbegin(std::move(x)); // should be ill-formed
ranges::cend(std::move(x));   // should be ill-formed

This might be a problem for ranges::crbegin and ranges::crend, but I haven't implemented any of rbegin, rend, crbegin, and crend to confirm as much.

History
Date User Action Args
2020-02-13 12:32:11adminsetmessages: + msg11062
2020-02-13 12:32:11adminsetstatus: new -> nad
2019-11-16 15:21:57adminsetmessages: + msg10817
2019-11-06 00:00:00admincreate