25 Iterators library [iterators]

25.5 Iterator adaptors [predef.iterators]

25.5.4 Move iterators and sentinels [move.iterators] Class template move_­sentinel [move.sentinel]

Class template move_­sentinel is a sentinel adaptor useful for denoting ranges together with move_­iterator.
When an input iterator type I and sentinel type S model sentinel_­for<S, I>, move_­sentinel<S> and move_­iterator<I> model sentinel_­for<move_­sentinel<S>, move_­iterator<I>> as well.
[Example 1:
A move_­if algorithm is easily implemented with copy_­if using move_­iterator and move_­sentinel: template<input_­iterator I, sentinel_­for<I> S, weakly_­incrementable O, indirect_­unary_­predicate<I> Pred> requires indirectly_­movable<I, O> void move_if(I first, S last, O out, Pred pred) { ranges::copy_if(move_iterator<I>{first}, move_sentinel<S>{last}, out, pred); }
— end example]
namespace std { template<semiregular S> class move_sentinel { public: constexpr move_sentinel(); constexpr explicit move_sentinel(S s); template<class S2> requires convertible_­to<const S2&, S> constexpr move_sentinel(const move_sentinel<S2>& s); template<class S2> requires assignable_­from<S&, const S2&> constexpr move_sentinel& operator=(const move_sentinel<S2>& s); constexpr S base() const; private: S last; // exposition only }; }