25 Algorithms library [algorithms]

25.6 Mutating sequence operations [alg.modifying.operations]

25.6.2 Move [alg.move]

template<class InputIterator, class OutputIterator> constexpr OutputIterator move(InputIterator first, InputIterator last, OutputIterator result); template<input_iterator I, sentinel_for<I> S, weakly_incrementable O> requires indirectly_movable<I, O> constexpr ranges::move_result<I, O> ranges::move(I first, S last, O result); template<input_range R, weakly_incrementable O> requires indirectly_movable<iterator_t<R>, O> constexpr ranges::move_result<safe_iterator_t<R>, O> ranges::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); template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2> requires indirectly_movable<I1, I2> constexpr ranges::move_backward_result<I1, I2> ranges::move_backward(I1 first, S1 last, I2 result); template<bidirectional_range R, bidirectional_iterator I> requires indirectly_movable<iterator_t<R>, I> constexpr ranges::move_backward_result<safe_iterator_t<R>, I> ranges::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.233
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).