tmp/tmp9izifpk1/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Class template `move_sentinel` <a id="move.sentinel">[[move.sentinel]]</a>
|
| 2 |
+
|
| 3 |
+
Class template `move_sentinel` is a sentinel adaptor useful for denoting
|
| 4 |
+
ranges together with `move_iterator`. When an input iterator type `I`
|
| 5 |
+
and sentinel type `S` model `sentinel_for<S, I>`, `move_sentinel<S>` and
|
| 6 |
+
`move_iterator<I>` model
|
| 7 |
+
`sentinel_for<move_sentinel<S>, move_iterator<I>{>}` as well.
|
| 8 |
+
|
| 9 |
+
[*Example 1*:
|
| 10 |
+
|
| 11 |
+
A `move_if` algorithm is easily implemented with `copy_if` using
|
| 12 |
+
`move_iterator` and `move_sentinel`:
|
| 13 |
+
|
| 14 |
+
``` cpp
|
| 15 |
+
template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
|
| 16 |
+
indirect_unary_predicate<I> Pred>
|
| 17 |
+
requires indirectly_movable<I, O>
|
| 18 |
+
void move_if(I first, S last, O out, Pred pred) {
|
| 19 |
+
std::ranges::copy_if(move_iterator<I>{first}, move_sentinel<S>{last}, out, pred);
|
| 20 |
+
}
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
— *end example*]
|
| 24 |
+
|
| 25 |
+
``` cpp
|
| 26 |
+
namespace std {
|
| 27 |
+
template<semiregular S>
|
| 28 |
+
class move_sentinel {
|
| 29 |
+
public:
|
| 30 |
+
constexpr move_sentinel();
|
| 31 |
+
constexpr explicit move_sentinel(S s);
|
| 32 |
+
template<class S2>
|
| 33 |
+
requires convertible_to<const S2&, S>
|
| 34 |
+
constexpr move_sentinel(const move_sentinel<S2>& s);
|
| 35 |
+
template<class S2>
|
| 36 |
+
requires assignable_from<S&, const S2&>
|
| 37 |
+
constexpr move_sentinel& operator=(const move_sentinel<S2>& s);
|
| 38 |
+
|
| 39 |
+
constexpr S base() const;
|
| 40 |
+
private:
|
| 41 |
+
S last; // exposition only
|
| 42 |
+
};
|
| 43 |
+
}
|
| 44 |
+
```
|
| 45 |
+
|