[move.iterator]

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

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

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

#### 24.5.4.2 Class template move_iterator [move.iterator]

[ð](#lib:move_iterator)

namespace std {template<class Iterator>class move_iterator {public:using iterator_type = Iterator; using iterator_concept = *see below*; using iterator_category = *see below*; // not always presentusing value_type = iter_value_t<Iterator>; using difference_type = iter_difference_t<Iterator>; using pointer = Iterator; using reference = iter_rvalue_reference_t<Iterator>; constexpr move_iterator(); constexpr explicit move_iterator(Iterator i); template<class U> constexpr move_iterator(const move_iterator<U>& u); template<class U> constexpr move_iterator& operator=(const move_iterator<U>& u); constexpr const Iterator& base() const & noexcept; constexpr Iterator base() &&; constexpr reference operator*() const; constexpr move_iterator& operator++(); constexpr auto operator++(int); constexpr move_iterator& operator--(); constexpr move_iterator operator--(int); constexpr move_iterator operator+(difference_type n) const; constexpr move_iterator& operator+=(difference_type n); constexpr move_iterator operator-(difference_type n) const; constexpr move_iterator& operator-=(difference_type n); constexpr reference operator[](difference_type n) const; template<[sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<Iterator> S>friend constexpr booloperator==(const move_iterator& x, const move_sentinel<S>& y); template<[sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<Iterator> S>friend constexpr iter_difference_t<Iterator>operator-(const move_sentinel<S>& x, const move_iterator& y); template<[sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<Iterator> S>friend constexpr iter_difference_t<Iterator>operator-(const move_iterator& x, const move_sentinel<S>& y); friend constexpr iter_rvalue_reference_t<Iterator> iter_move(const move_iterator& i)noexcept(noexcept(ranges::iter_move(i.current))); template<[indirectly_swappable](alg.req.ind.swap#concept:indirectly_swappable "24.3.7.4 Concept indirectly_­swappable [alg.req.ind.swap]")<Iterator> Iterator2>friend constexpr void iter_swap(const move_iterator& x, const move_iterator<Iterator2>& y)noexcept(noexcept(ranges::iter_swap(x.current, y.current))); private: Iterator current; // *exposition only*};}

[1](#1)

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

The member [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]") iterator_concept is defined
as follows:

- [(1.1)](#1.1)

  If Iterator models [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]"),
then iterator_concept denotes random_access_iterator_tag[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  Otherwise, if Iterator models [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]"),
then iterator_concept denotes bidirectional_iterator_tag[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  Otherwise, if Iterator models [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]"),
then iterator_concept denotes forward_iterator_tag[.](#1.3.sentence-1)

- [(1.4)](#1.4)

  Otherwise, iterator_concept denotes input_iterator_tag[.](#1.4.sentence-1)

[2](#2)

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

The member [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]") iterator_category is defined
if and only if the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")iterator_traits<Iterator>​::​iterator_category is valid and denotes a type[.](#2.sentence-1)

In that case, iterator_category denotes

- [(2.1)](#2.1)

random_access_iterator_tag if
the typeiterator_traits<​Iterator>​::​iterator_category models[derived_from](concept.derived#concept:derived_from "18.4.3 Concept derived_­from [concept.derived]")<random_access_iterator_tag>, and

- [(2.2)](#2.2)

iterator_traits<​Iterator>​::​iterator_category otherwise[.](#2.sentence-2)
