24 Algorithms library [algorithms]

24.6 Mutating sequence operations [alg.modifying.operations]

24.6.2 Move [alg.move]

template<class InputIterator, class OutputIterator> constexpr OutputIterator move(InputIterator first, InputIterator last, OutputIterator result); namespace ranges { template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O> requires IndirectlyMovable<I, O> constexpr move_result<I, O> move(I first, S last, O result); template<InputRange R, WeaklyIncrementable O> requires IndirectlyMovable<iterator_t<R>, O> constexpr move_result<safe_iterator_t<R>, O> move(R&& r, O result); }
Let E be
  • std::move(*(first + n)) for the overload in namespace std, or
  • ranges::iter_­move(first + n) for the overloads in namespace ranges.
Let N be last - first.
Requires: result shall not be in the range [first, last).
Effects: Moves elements in the range [first, last) into the range [result, result + N) starting from first and proceeding to last.
For each non-negative integer , performs *(result + n) = E.
Returns:
  • result + N for the overload in namespace std, or
  • {last, result + N} for the overloads in namespace ranges.
Complexity: Exactly N assignments.
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2> ForwardIterator2 move(ExecutionPolicy&& policy, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result);
Let N be last - first.
Requires: The ranges [first, last) and [result, result + N) shall not overlap.
Effects: Moves elements in the range [first, last) into the range [result, result + N).
For each non-negative integer , performs *(result + n) = std::​move(*(first + n)).
Returns: result + N.
Complexity: Exactly N assignments.
template<class BidirectionalIterator1, class BidirectionalIterator2> constexpr BidirectionalIterator2 move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result); namespace ranges { template<BidirectionalIterator I1, Sentinel<I1> S1, BidirectionalIterator I2> requires IndirectlyMovable<I1, I2> constexpr move_backward_result<I1, I2> move_backward(I1 first, S1 last, I2 result); template<BidirectionalRange R, BidirectionalIterator I> requires IndirectlyMovable<iterator_t<R>, I> constexpr move_backward_result<safe_iterator_t<R>, I> move_backward(R&& r, I result); }
Let E be
  • std::move(*(last - n)) for the overload in namespace std, or
  • ranges::iter_­move(last - n) for the overloads in namespace ranges.
Let N be last - first.
Requires: result shall not be in the range (first, last].
Effects: Moves elements in the range [first, last) into the range [result - N, result) starting from last - 1 and proceeding to first.235
For each positive integer , performs *(result - n) = E.
Returns:
  • result - N for the overload in namespace std, or
  • {last, result - N} for the overloads in namespace ranges.
Complexity: Exactly N assignments.
move_­backward should be used instead of move when last is in the range [result - N, result).