
ALINK="#ff0000">
swap_ranges
Prototypetemplate <class ForwardIterator1, class ForwardIterator2> ForwardIterator2 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); DescriptionSwap_ranges swaps each of the elements in the range [first1, last1) with the corresponding element in the range [first2, first2 + (last1  first1)). That is, for each integer n such that 0 <= n < (last1  first1), it swaps *(first1 + n) and *(first2 + n). The return value is first2 + (last1  first1).DefinitionDefined in the standard header algorithm, and in the nonstandard backwardcompatibility header algo.h.Requirements on typesForwardIterator1 and ForwardIterator2 must both be models of Forward Iterator. The value types of ForwardIterator1 and ForwardIterator2 must be convertible to each other.Preconditions
ComplexityLinear. Exactly last1  first1 swaps are performed.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 alsoswap, iter_swap.Copyright © 1999 Silicon Graphics, Inc. All Rights Reserved. TrademarkInformation
