views::reverse
should be specialized for some view typesSection: 25.7.21.1 [range.reverse.overview] Status: LEWG Submitter: Hewill Kang Opened: 2024-05-09 Last modified: 2024-06-24
Priority: 3
View all issues with LEWG status.
Discussion:
Currently, when views::reverse
is applied to empty_view
, single_view
, or
repeat_view
, a reverse_view
with the iterator type reverse_iterator
will
be produced.
views::repeat(0) | views::reverse | views::take(5)
no longer timeout,
which seems to be an improvement.
[2024-06-24; Reflector poll]
Set priority to 3 after reflector poll. Send to LEWG for review.
The repeat
part is related to LWG 4019.
Proposed resolution:
This wording is relative to N4981.
Modify 25.7.21.1 [range.reverse.overview] as indicated:
-1-
-2- The namereverse_view
takes a bidirectional view and produces another view that iterates the same elements in reverse order.views::reverse
denotes a range adaptor object (25.7.2 [range.adaptor.object]). Given a subexpressionE
, the expressionviews::reverse(E)
is expression-equivalent to:
(2.1) — If the type of
E
is a (possibly cv-qualified) specialization ofreverse_view
, equivalent toE.base()
.(2.?) — Otherwise, if the type of
E
is a (possibly cv-qualified) specialization ofempty_view
(25.6.2.2 [range.empty.view]),single_view
(25.6.3.2 [range.single.view]), orrepeat_view
(25.6.5.2 [range.repeat.view]), equivalent todecay-copy(E)
.(2.2) — Otherwise, if the type of
E
is cvsubrange<reverse_iterator<I>, reverse_iterator<I>, K>
for some iterator typeI
and valueK
of typesubrange_kind
,
(2.2.1) — if
K
issubrange_kind::sized
, equivalent to:subrange<I, I, K>(E.end().base(), E.begin().base(), E.size())(2.2.2) — otherwise, equivalent to:
subrange<I, I, K>(E.end().base(), E.begin().base())However, in either case
E
is evaluated only once.(2.3) — Otherwise, equivalent to
reverse_view{E}
.