25 Algorithms library [algorithms]

25.3 Mutating sequence operations [alg.modifying.operations]

25.3.11 Rotate [alg.rotate]

template<class ForwardIterator> ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);

Effects: For each non-negative integer i < (last - first), places the element from the position first + i into position first + (i + (last - middle)) % (last - first).

Returns: first + (last - middle).

Remarks: This is a left rotate.

Requires: [first,middle) and [middle,last) shall be valid ranges. ForwardIterator shall satisfy the requirements of ValueSwappable ([swappable.requirements]). The type of *first shall satisfy the requirements of MoveConstructible (Table [moveconstructible]) and the requirements of MoveAssignable (Table [moveassignable]).

Complexity: At most last - first swaps.

template<class ForwardIterator, class OutputIterator> OutputIterator rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);

Effects: Copies the range [first,last) to the range [result,result + (last - first)) such that for each non-negative integer i < (last - first) the following assignment takes place: *(result + i) = *(first + (i + (middle - first)) % (last - first)).

Returns: result + (last - first).

Requires: The ranges [first,last) and [result,result + (last - first)) shall not overlap.

Complexity: Exactly last - first assignments.