26
Ranges library
[ranges]
26.7
Range adaptors
[range.adaptors]
26.7.20
Reverse view
[range.reverse]
26.7.20.1
Overview
[range.reverse.overview]
1
#
reverse_
view
takes a bidirectional view and produces another view that iterates the same elements in reverse order
.
2
#
The name
views
::
reverse
denotes a range adaptor object (
[range.
adaptor.
object]
)
.
Given a subexpression
E
, the expression
views
::
reverse
(
E
)
is expression-equivalent to:
(2.1)
If the type of
E
is a (possibly cv-qualified) specialization of
reverse_
view
, equivalent to
E
.
base
(
)
.
(2.2)
Otherwise, if the type of
E
is
cv
subrange
<
reverse_
iterator
<
I
>
, reverse_
iterator
<
I
>
, K
>
for some iterator type
I
and value
K
of type
subrange_
kind
,
(2.2.1)
if
K
is
subrange_
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
}
.
3
#
[
Example
1
:
vector
<
int
>
is
{
0
,
1
,
2
,
3
,
4
}
;
for
(
int
i
:
is
|
views
::
reverse
)
cout
<
<
i
<
<
' '
;
// prints
4 3 2 1 0
—
end example
]