swap_ranges
Prototypetemplate <class ForwardIterator1, class ForwardIterator2> ForwardIterator2 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); Description
DefinitionDefined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h. Requirements on types
Preconditions
ComplexityLinear. Exactly ExampleVector<int> V1, V2; V1.push_back(1); V1.push_back(2); V2.push_back(3); V2.push_back(4); assert(V1[0] == 1 && V1[1] == 2 && V2[0] == 3 && V2[1] == 4); swap_ranges(V1.begin(), V1.end(), V2.begin()); assert(V1[0] == 3 && V1[1] == 4 && V2[0] == 1 && V2[1] == 2); NotesSee also |