Class template move_iterator is an iterator adaptor with the same behavior as the underlying iterator except that its indirection operator implicitly converts the value returned by the underlying iterator's indirection operator to an rvalue of the value type. Some generic algorithms can be called with move iterators to replace copying with moving.
[ Example:
list<string> s; // populate the list s vector<string> v1(s.begin(), s.end()); // copies strings into v1 vector<string> v2(make_move_iterator(s.begin()), make_move_iterator(s.end())); // moves strings into v2
— end example ]
namespace std { namespace experimental { namespace ranges { inline namespace v1 { template <InputIterator I> class move_iterator { public: using iterator_type = I; using difference_type = difference_type_t<I>; using value_type = value_type_t<I>; using iterator_category = input_iterator_tag; using reference = rvalue_reference_t<I>; constexpr move_iterator(); explicit constexpr move_iterator(I i); constexpr move_iterator(const move_iterator<ConvertibleTo<I>>& i); constexpr move_iterator& operator=(const move_iterator<ConvertibleTo<I>>& i); constexpr I base() const; constexpr reference operator*() const; constexpr move_iterator& operator++(); constexpr void operator++(int); constexpr move_iterator operator++(int) requires ForwardIterator<I>; constexpr move_iterator& operator--() requires BidirectionalIterator<I>; constexpr move_iterator operator--(int) requires BidirectionalIterator<I>; constexpr move_iterator operator+(difference_type n) const requires RandomAccessIterator<I>; constexpr move_iterator& operator+=(difference_type n) requires RandomAccessIterator<I>; constexpr move_iterator operator-(difference_type n) const requires RandomAccessIterator<I>; constexpr move_iterator& operator-=(difference_type n) requires RandomAccessIterator<I>; constexpr reference operator[](difference_type n) const requires RandomAccessIterator<I>; friend constexpr rvalue_reference_t<I> iter_move(const move_iterator& i) noexcept(see below); template <IndirectlySwappable<I> I2> friend constexpr void iter_swap(const move_iterator& x, const move_iterator<I2>& y) noexcept(see below); private: I current; // exposition only }; template <class I1, class I2> requires EqualityComparableWith<I1, I2> constexpr bool operator==( const move_iterator<I1>& x, const move_iterator<I2>& y); template <class I1, class I2> requires EqualityComparableWith<I1, I2> constexpr bool operator!=( const move_iterator<I1>& x, const move_iterator<I2>& y); template <class I1, class I2> requires StrictTotallyOrderedWith<I1, I2> constexpr bool operator<( const move_iterator<I1>& x, const move_iterator<I2>& y); template <class I1, class I2> requires StrictTotallyOrderedWith<I1, I2> constexpr bool operator<=( const move_iterator<I1>& x, const move_iterator<I2>& y); template <class I1, class I2> requires StrictTotallyOrderedWith<I1, I2> constexpr bool operator>( const move_iterator<I1>& x, const move_iterator<I2>& y); template <class I1, class I2> requires StrictTotallyOrderedWith<I1, I2> constexpr bool operator>=( const move_iterator<I1>& x, const move_iterator<I2>& y); template <class I1, class I2> requires SizedSentinel<I1, I2> constexpr difference_type_t<I2> operator-( const move_iterator<I1>& x, const move_iterator<I2>& y); template <RandomAccessIterator I> constexpr move_iterator<I> operator+( difference_type_t<I> n, const move_iterator<I>& x); template <InputIterator I> constexpr move_iterator<I> make_move_iterator(I i); }}}}
[ Note: move_iterator does not provide an operator-> because the class member access expression i->m may have different semantics than the expression (*i).m when the expression *i is an rvalue. — end note ]