11 Algorithms library [algorithms]

11.4 Mutating sequence operations [alg.modifying.operations]

11.4.3 swap [alg.swap]

template <ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2> requires IndirectlySwappable<I1, I2> tagged_pair<tag::in1(I1), tag::in2(I2)> swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2); template <ForwardRange Rng1, ForwardRange Rng2> requires IndirectlySwappable<iterator_t<Rng1>, iterator_t<Rng2>> tagged_pair<tag::in1(safe_iterator_t<Rng1>), tag::in2(safe_iterator_t<Rng2>)> swap_ranges(Rng1&& rng1, Rng2&& rng2);

Effects: For each non-negative integer n < min(last1 - first1, last2 - first2) performs:
ranges::iter_swap(first1 + n, first2 + n).

Requires: The two ranges [first1,last1) and [first2,last2) shall not overlap. *(first1 + n) shall be swappable with ([concepts.lib.corelang.swappable]) *(first2 + n).

Returns: {first1 + n, first2 + n}, where n is min(last1 - first1, last2 - first2).

Complexity: Exactly min(last1 - first1, last2 - first2) swaps.