Files
cppdraft_translate/cppdraft/move/sentinel.md
2025-10-25 03:02:53 +03:00

2.8 KiB

[move.sentinel]

24 Iterators library [iterators]

24.5 Iterator adaptors [predef.iterators]

24.5.4 Move iterators and sentinels [move.iterators]

24.5.4.10 Class template move_sentinel [move.sentinel]

1

#

Class template move_sentinel is a sentinel adaptor useful for denoting ranges together with move_iterator.

When an input iterator typeI and sentinel type S model sentinel_for<S, I>,move_sentinel and move_iterator modelsentinel_for<move_sentinel, move_iterator> as well.

2

#

[Example 1:

A move_if algorithm is easily implemented withcopy_if using move_iterator and move_sentinel:template<input_iterator I, sentinel_for S, weakly_incrementable O, indirect_unary_predicate Pred>requires indirectly_movable<I, O>void move_if(I first, S last, O out, Pred pred) { ranges::copy_if(move_iterator{std::move(first)}, move_sentinel{last}, std::move(out), pred);}

— end example]

🔗

namespace std {template<semiregular S>class move_sentinel {public:constexpr move_sentinel(); constexpr explicit move_sentinel(S s); templaterequires convertible_to<const S2&, S>constexpr move_sentinel(const move_sentinel& s); templaterequires assignable_from<S&, const S2&>constexpr move_sentinel& operator=(const move_sentinel& s); constexpr S base() const; private: S last; // exposition only};}