25
Ranges library
[ranges]
25.7
Range adaptors
[range.adaptors]
25.7.7
As rvalue view
[range.as.rvalue]
25.7.7.1
Overview
[range.as.rvalue.overview]
1
#
as_
rvalue_
view
presents a view of an underlying sequence with the same behavior as the underlying sequence except that its elements are rvalues
.
Some generic algorithms can be called with an
as_
rvalue_
view
to replace copying with moving
.
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:
(2.1)
views
::
all
(
E
)
if
T
models
input_
range
and
same_
as
<
range_
rvalue_
reference_
t
<
T
>
, range_
reference_
t
<
T
>
>
is
true
.
(2.2)
Otherwise,
as_
rvalue_
view
(
E
)
.
3
#
[
Example
1
:
vector
<
string
>
words
=
{
"the"
,
"quick"
,
"brown"
,
"fox"
,
"ate"
,
"a"
,
"pterodactyl"
}
; vector
<
string
>
new_words; ranges
::
copy
(
words
|
views
::
as_rvalue, back_inserter
(
new_words
)
)
;
// moves each string from
words
into
new_
words
—
end example
]