25 Algorithms library [algorithms]

25.7 Mutating sequence operations [alg.modifying.operations]

25.7.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<borrowed_iterator_t<R>, O> ranges::move(R&& r, O result);
Let E be
  • std​::​move(*(first + n)) for the overload in namespace std;
  • ranges​::​iter_­move(first + n) for the overloads in namespace ranges.
Let N be last - first.
Preconditions: result is not 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.
  • {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.
Preconditions: The ranges [first, last) and [result, result + N) do 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<borrowed_iterator_t<R>, I> ranges::move_backward(R&& r, I result);
Let E be
  • std​::​move(*(last - n)) for the overload in namespace std;
  • ranges​::​iter_­move(last - n) for the overloads in namespace ranges.
Let N be last - first.
Preconditions: result is not 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.238
For each positive integer , performs *(result - n) = E.
Returns:
  • result - N for the overload in namespace std.
  • {last, result - N} for the overloads in namespace ranges.
Complexity: Exactly N assignments.
move_­backward can be used instead of move when last is in the range [result - N, result).
 â®¥