Description
swap() is used to swap two elements in a standard container such as a vector. swap() uses a temporary to do the actual swapping.
Declaration
template <class T> void swap(T& a, T& b);
Concept
The sample code illustrates a simple use of swap() in swapping two numbers. A vector is set up and then the first two elements of it are exchanged.
Special Notes:
There are specialized versions of swap() that are more efficient for particular container types such as vector. For example, a specialized version could swap pointers or references to objects instead of the objects themselves.
Supported
Supported
Supported