std::swap
From cppreference.com
Defined in header <algorithm>
Defined in header <utility> |
(until C++11) (since C++11) |
|
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) | (since C++11) |
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: (since C++11)
noexcept(noexcept( std::is_nothrow_move_constructible<T>::value && |
||
2) noexcept specification: (since C++11)
noexcept(noexcept(swap(*a, *b))) |
||
[edit] Complexity
Constant
[edit] Specializations
Custom specializations of the std::swap algorithm are allowed. The following specializations are already provided by the standard library:
(C++11) |
specializes the std::swap algorithm (function template) |
(C++11) |
specializes the std::swap algorithm (function template) |
(C++11) |
specializes the std::swap algorithm (function template) |
(C++11) |
specializes the std::swap algorithm (function template) |
(C++11) |
specializes the std::swap algorithm (function template) |
(C++11) |
specializes the std::swap algorithm (function template) |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
(C++11) |
specializes the std::swap() algorithm (function template) |
specializes the std::swap() algorithm (function template) | |
specializes the std::swap() algorithm (function template) | |
specializes the std::swap() algorithm (function template) | |
specializes the std::swap() algorithm (function template) | |
specializes the std::swap() algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
specializes the std::swap algorithm (function template) | |
(C++11) |
specializes the std::swap() algorithm (function template) |
specializes the std::swap() algorithm (function template) | |
(C++11) |
specializes the std::swap algorithm (function template) |
(C++11) |
specializes the std::swap() algorithm (function template) |
(C++11) |
specializes the std::swap() algorithm (function template) |
specializes the std::swap() algorithm (function template) |
[edit] Example
This section is incomplete Reason: no example |
[edit] See also
swaps the elements pointed to by two iterators (function template) | |
swaps two ranges of elements (function template) |