std::swap
From Cppreference
Defined in header <algorithm>
Defined in header <utility> | (pre-C++11 version)
(C++11 version) | |
template< class T >
void swap( T& a, T& b ); | (1) | |
template< class T, size_t N >
void swap( T (&a)[N], T (&b)[N]); | (2) | (C++11 feature) |
Exchanges the given values.
1) Swaps the values a and b.
2) Swaps the arrays a and b. In effect calls std::swap_ranges(a, a+N, b).
Contents |
[edit] Parameters
a, b | - | the values to be swapped |
[edit] Return value
(none)
[edit] Exceptions
1) noexcept specification: (C++11 feature)
noexcept(noexcept(
std::is_nothrow_move_constructible<Assignable>::value && | ||
2) noexcept specification: (C++11 feature)
noexcept(noexcept(swap(*a, *b)))
| ||
[edit] Example
This section is incomplete |
[edit] Complexity
constant
[edit] See also
| swaps the elements pointed to by two iterators (function template) | |
| swaps two ranges of elements (function template) |