This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
views::as_rvalue
and views::common
are not strictly correctSection: 26.7.7.1 [range.as.rvalue.overview], 26.7.20.1 [range.common.overview] Status: New Submitter: Hewill Kang Opened: 2024-05-10 Last modified: 2024-06-24
Priority: 4
View all other issues in [range.as.rvalue.overview].
View all issues with New status.
Discussion:
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.
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))
.
[2024-06-24; Reflector poll]
Set priority to 4 after reflector poll.
"Not aware of any use case for making const
affect those properties".
Proposed resolution:
This wording is relative to N4981.
Modify 26.7.7.1 [range.as.rvalue.overview] as indicated:
-2- The name
views::as_rvalue
denotes a range adaptor object (26.7.2 [range.adaptor.object]). LetE
be an expression and letT
bedecltype((E))
. The expressionviews::as_rvalue(E)
is expression-equivalent to:
(2.1) —
views::all(E)
ifsame_as<range_rvalue_reference_t<views::all_t<T>>, range_reference_t<views::all_t<T>>>
istrue
.(2.2) — Otherwise,
as_rvalue_view(E)
.
Modify 26.7.20.1 [range.common.overview] as indicated:
-3- The name
views::common
denotes a range adaptor object (26.7.2 [range.adaptor.object]). Given a subexpressionE
, the expressionviews::common(E)
is expression-equivalent to:
(3.1) —
views::all(E)
, ifdecltype((E))
views::all_t<T>
modelscommon_range
and.views::all(E)
is a well-formed expression(3.2) — Otherwise,
common_view{E}
.