This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
views::as_rvalue
should reject non-input rangesSection: 26.7.7.1 [range.as.rvalue.overview] Status: WP Submitter: Hewill Kang Opened: 2024-04-27 Last modified: 2024-07-08
Priority: Not Prioritized
View all other issues in [range.as.rvalue.overview].
View all issues with WP status.
Discussion:
views::as_rvalue(r)
equivalent to views::all(r)
when r
's reference and rvalue reference are
of the same type, which means that in this case we only need to check whether the type of r
models viewable_range
.
as_rvalue_view{r}
to be valid, which leads to
divergence when r
is not an input_range
(demo):
#include <ranges>
struct I {
int operator*();
using difference_type = int;
I& operator++();
void operator++(int);
};
std::ranges::range auto r = std::ranges::subrange{I{}, std::unreachable_sentinel}
| std::views::as_rvalue; // // well-formed in libc++/MSVC-STL, ill-formed in libstdc++
Although this is precisely a bug in libstdc++ that does not conform to the current wording, it is reasonable to
require r
to be an input_range
to be consistent with the constraints of as_rvalue_view
.
[2024-05-08; Reflector poll]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
[St. Louis 2024-06-29; Status changed: Voting → WP.]
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)
ifT
modelsinput_range
andsame_as<range_rvalue_reference_t<T>, range_reference_t<T>>
istrue
.(2.2) — Otherwise,
as_rvalue_view(E)
.