Translations of this page?:

swap_ranges

#include <algorithm>
 
template< class ForwardIterator1, class ForwardIterator2 >
ForwardIterator2 swap_ranges( ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator1 first2 )

Exchanges elements between two given ranges: one defined by [first1, last1) and another starting at first2.

Parameters

first1, last1 - the first range of the elements to be swapped

first2 - beginning of the second range of the elements to be swapped

Return value

iterator to the element past the last element exchanged in the range beginning with first2.

Equivalent function

template<class ForwardIterator1, class ForwardIterator2>
ForwardIterator1 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator1 first2)
{
    while (first1 != last1) {
        std::iter_swap(first1++, first2++);
    }
    return first2;
}

Complexity

linear in the distance between first and last.

See also

 
• • • SitemapRecent changesRSScc