tmp/tmpp0fcl48f/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Overview <a id="range.as.rvalue.overview">[[range.as.rvalue.overview]]</a>
|
| 2 |
+
|
| 3 |
+
`as_rvalue_view` presents a view of an underlying sequence with the same
|
| 4 |
+
behavior as the underlying sequence except that its elements are
|
| 5 |
+
rvalues. Some generic algorithms can be called with an `as_rvalue_view`
|
| 6 |
+
to replace copying with moving.
|
| 7 |
+
|
| 8 |
+
The name `views::as_rvalue` denotes a range adaptor object
|
| 9 |
+
[[range.adaptor.object]]. Let `E` be an expression and let `T` be
|
| 10 |
+
`decltype((E))`. The expression `views::as_rvalue(E)` is
|
| 11 |
+
expression-equivalent to:
|
| 12 |
+
|
| 13 |
+
- `views::all(E)` if
|
| 14 |
+
`same_as<range_rvalue_reference_t<T>, range_reference_t<T>>` is
|
| 15 |
+
`true`.
|
| 16 |
+
- Otherwise, `as_rvalue_view(E)`.
|
| 17 |
+
|
| 18 |
+
[*Example 1*:
|
| 19 |
+
|
| 20 |
+
``` cpp
|
| 21 |
+
vector<string> words = {"the", "quick", "brown", "fox", "ate", "a", "pterodactyl"};
|
| 22 |
+
vector<string> new_words;
|
| 23 |
+
ranges::copy(words | views::as_rvalue, back_inserter(new_words));
|
| 24 |
+
// moves each string from words into new_words
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
— *end example*]
|
| 28 |
+
|