The behavior of this function template is equivalent to:
| 1 2 3 4 5 6 7 |
|
Parameters
- first1, last1
- Forward iterators to the initial and final positions in one of the sequences to be swapped. The range used is [first1,last1), which contains all the elements between first1 and last1, including the element pointed by first1 but not the element pointed by last1.
- first2
- Forward iterator to the initial position in the other sequence to be swapped. The range used includes the same number of elements as the range [first1,last1).
The two ranges shall not overlap.
Return value
An iterator to the last element swapped in the second sequence.Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
Output:
first contains: 10 33 33 33 10 second contains: 10 10 10 33 33 |
Complexity
Linear: Performs as many swaps as elements are in the range [first1,last1).See also
| swap | Exchange values of two objects (function template) |
| iter_swap | Exchange values of objects pointed by two iterators (function template) |
| replace | Replace value in range (function template) |
