C++ Algorithm swap_ranges()
C++ Algorithm swap_ranges() exchanges the elements in the range [first1, last2) with the elements present in the range starting from first2.
In short we can say that, swap_ranges() swaps the elements of two sequence, that is each element at a position in the first sequence is replaced by the element at the same position in the second sequence and vice-versa is also possible.
Syntax
Parameter
first1: A forward iterator pointing to the first position of the first range whose elements is to be swapped.
last1: A forward iterator pointing to one past the final position of the first range whose elements are to be swapped.
first2: A forward iterator pointing to the first position of the second range whose elements is to be swapped.
Return value
swap_ranges() returns an iterator pointing to the end of the second range whose elements are to be exchanged.