[move.sentinel]

# 24 Iterators library [[iterators]](./#iterators)

## 24.5 Iterator adaptors [[predef.iterators]](predef.iterators#move.sentinel)

### 24.5.4 Move iterators and sentinels [[move.iterators]](move.iterators#move.sentinel)

#### 24.5.4.10 Class template move_sentinel [move.sentinel]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L5301)

Class template move_sentinel is a sentinel adaptor useful for denoting
ranges together with move_iterator[.](#1.sentence-1)

When an input iterator typeI and sentinel type S model [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<S, I>,move_sentinel<S> and move_iterator<I> model[sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<move_sentinel<S>, move_iterator<I>> as well[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L5308)

[*Example [1](#example-1)*:

A move_if algorithm is easily implemented withcopy_if using move_iterator and move_sentinel:template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<I> S, [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]") O, [indirect_unary_predicate](indirectcallable.indirectinvocable#concept:indirect_unary_predicate "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<I> Pred>requires [indirectly_movable](alg.req.ind.move#concept:indirectly_movable "24.3.7.2 Concept indirectly_­movable [alg.req.ind.move]")<I, O>void move_if(I first, S last, O out, Pred pred) { ranges::copy_if(move_iterator<I>{std::move(first)}, move_sentinel<S>{last},
 std::move(out), pred);}

â *end example*]

[ð](#lib:move_sentinel)

namespace std {template<[semiregular](concepts.object#concept:semiregular "18.6 Object concepts [concepts.object]") S>class move_sentinel {public:constexpr move_sentinel(); constexpr explicit move_sentinel(S s); template<class S2>requires [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<const S2&, S>constexpr move_sentinel(const move_sentinel<S2>& s); template<class S2>requires [assignable_from](concept.assignable#concept:assignable_from "18.4.8 Concept assignable_­from [concept.assignable]")<S&, const S2&>constexpr move_sentinel& operator=(const move_sentinel<S2>& s); constexpr S base() const; private: S last; // *exposition only*};}
