# 11 Algorithms library [algorithms]

## 11.4 Mutating sequence operations [alg.modifying.operations]

### 11.4.2 Move [alg.move]

``` template <InputIterator I, Sentinel<I> S, WeaklyIncrementable O> requires IndirectlyMovable<I, O> tagged_pair<tag::in(I), tag::out(O)> move(I first, S last, O result); template <InputRange Rng, WeaklyIncrementable O> requires IndirectlyMovable<iterator_t<Rng>, O> tagged_pair<tag::in(safe_iterator_t<Rng>), tag::out(O)> move(Rng&& rng, O result); ```

Effects: Moves elements in the range [first,last) into the range [result,result + (last - first)) starting from first and proceeding to last. For each non-negative integer n < (last-first), performs *(result + n) = ranges::iter_move(first + n).

Returns: {last, result + (last - first)}.

Requires: result shall not be in the range [first,last).

Complexity: Exactly last - first move assignments.

``` template <BidirectionalIterator I1, Sentinel<I1> S1, BidirectionalIterator I2> requires IndirectlyMovable<I1, I2> tagged_pair<tag::in(I1), tag::out(I2)> move_backward(I1 first, S1 last, I2 result); template <BidirectionalRange Rng, BidirectionalIterator I> requires IndirectlyMovable<iterator_t<Rng>, I> tagged_pair<tag::in(safe_iterator_t<Rng>), tag::out(I)> move_backward(Rng&& rng, I result); ```

Effects: Moves elements in the range [first,last) into the range [result - (last-first),result) starting from last - 1 and proceeding to first.6 For each positive integer n <= (last - first), performs *(result - n) = ranges::iter_move(last - n).

Requires: result shall not be in the range (first,last].

Returns: {last, result - (last - first)}.

Complexity: Exactly last - first assignments.

move_backward should be used instead of move when last is in the range [result - (last - first),result).