Name

swap function template — Swaps two values

Synopsis

template<typename T> void swap(T& a, T& b);

The swap function template swaps the values of a and b.

The standard containers all specialize the swap template to call their swap member functions, which usually run in constant time, regardless of the number of elements in the containers.

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.