11 Algorithms library [algorithms]

11.4 Mutating sequence operations [alg.modifying.operations]

11.4.10 Reverse [alg.reverse]

template <BidirectionalIterator I, Sentinel<I> S> requires Permutable<I> I reverse(I first, S last); template <BidirectionalRange Rng> requires Permutable<iterator_t<Rng>> safe_iterator_t<Rng> reverse(Rng&& rng);

Effects: For each non-negative integer i < (last - first)/2, applies iter_swap to all pairs of iterators first + i, (last - i) - 1.

Returns: last.

Complexity: Exactly (last - first)/2 swaps.

template <BidirectionalIterator I, Sentinel<I> S, WeaklyIncrementable O> requires IndirectlyCopyable<I, O> tagged_pair<tag::in(I), tag::out(O)> reverse_copy(I first, S last, O result); template <BidirectionalRange Rng, WeaklyIncrementable O> requires IndirectlyCopyable<iterator_t<Rng>, O> tagged_pair<tag::in(safe_iterator_t<Rng>), tag::out(O)> reverse_copy(Rng&& rng, O result);

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

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

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

Complexity: Exactly last - first assignments.