Title
The simple case of views::as_rvalue and views::common are not strictly correct
Status
new
Section
[range.as.rvalue.overview][range.common.overview]
Submitter
Hewill Kang

Created on 2024-05-10.00:00:00 last changed 4 months ago

Messages

Date: 2024-06-24.12:09:57

Proposed resolution:

This wording is relative to N4981.

  1. Modify [range.as.rvalue.overview] as indicated:

    -2- The name views::as_rvalue denotes a range adaptor object ([range.adaptor.object]). Let E be an expression and let T be decltype((E)). The expression views::as_rvalue(E) is expression-equivalent to:

    1. (2.1) — views::all(E) if same_as<range_rvalue_reference_t<views::all_t<T>>, range_reference_t<views::all_t<T>>> is true.

    2. (2.2) — Otherwise, as_rvalue_view(E).

  2. Modify [range.common.overview] as indicated:

    -3- The name views::common denotes a range adaptor object ([range.adaptor.object]). Given a subexpression E, the expression views::common(E) is expression-equivalent to:

    1. (3.1) — views::all(E), if decltype((E))views::all_t<T> models common_range and views::all(E) is a well-formed expression.

    2. (3.2) — Otherwise, common_view{E}.

Date: 2024-06-15.00:00:00

[ 2024-06-24; Reflector poll ]

Set priority to 4 after reflector poll. "Not aware of any use case for making `const` affect those properties".

Date: 2024-05-10.00:00:00

Currently, these two adaptors return views::all(E) when the type of subexpression E models common_range or its reference is the same as the rvalue reference.

However, the current wording does not require that a const-qualified object of a range type must have the same non-commonality or value category of the reference as the non-const one, this makes it theoretically possible for these two to still return non-common ranges or ranges whose reference are lvalue when acting on a const-qualified lvalue view object, because views::all(E) will remove the const-qualifier.

The proposed wording pedantically checks views::all_t<decltype((E))> instead of decltype((E)).

History
Date User Action Args
2024-06-24 12:09:57adminsetmessages: + msg14191
2024-05-12 11:08:33adminsetmessages: + msg14136
2024-05-10 00:00:00admincreate