Name
swap_ranges function template — Swaps all values in two ranges
Synopsis
template<typename FwdIter1, typename FwdIter2>
FwdIter2 swap_ranges(FwdIter1 first1, FwdIter1 last1, FwdIter2 first2);
The swap_ranges
function
template swaps all the elements in [first1
, last1
) with corresponding elements in the
range that starts at first2
(and
has the same length as the first range). The return value is one
past the end of the second range. The two ranges must not
overlap.
Technical Notes
The swap_ranges
function
template performs the equivalent of
swap(*(first1 + n), *(first2 + n)) for all n in [0, last1 - first1).
Complexity is linear: exactly last1 - first1 swaps are performed.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.