Difference between revisions of "cpp/utility/pair/swap2"
From cppreference.com
(p0185r1, langlinks) |
(P1032R1, shorten) |
||
Line 1: | Line 1: | ||
{{cpp/title | swap<small>(std::pair)</small>}} | {{cpp/title | swap<small>(std::pair)</small>}} | ||
{{cpp/utility/pair/navbar}} | {{cpp/utility/pair/navbar}} | ||
− | {{ | + | {{dcl begin}} |
+ | {{dcl header | utility}} | ||
+ | {{dcl rev multi | since1=c++11 | dcl1= | ||
template< class T1, class T2 > | template< class T1, class T2 > | ||
− | void swap( pair<T1,T2>& | + | void swap( pair<T1,T2>& x, pair<T1,T2>& y ) noexcept(/* see below */); |
+ | | since2=c++20 | dcl2= | ||
+ | template< class T1, class T2 > | ||
+ | constexpr void swap( pair<T1,T2>& x, pair<T1,T2>& y ) noexcept(/* see below */); | ||
}} | }} | ||
+ | {{dcl end}} | ||
− | Swaps the contents of {{tt| | + | Swaps the contents of {{tt|x}} and {{tt|y}}. Equivalent to {{c|x.swap(y)}}. |
− | {{ | + | {{rrev|since=c++17| |
− | + | ||
This function does not participate in overload resolution unless {{c|std::is_swappable_v<first_type> && std::is_swappable_v<second_type>}} is {{c|true}}. | This function does not participate in overload resolution unless {{c|std::is_swappable_v<first_type> && std::is_swappable_v<second_type>}} is {{c|true}}. | ||
}} | }} | ||
− | |||
===Parameters=== | ===Parameters=== | ||
{{par begin}} | {{par begin}} | ||
− | {{par | | + | {{par | x, y | pairs whose contents to swap}} |
{{par end}} | {{par end}} | ||
Line 23: | Line 27: | ||
===Exceptions=== | ===Exceptions=== | ||
− | {{noexcept|noexcept( | + | {{noexcept|noexcept(x.swap(y))}} |
===See also=== | ===See also=== |
Revision as of 21:32, 18 November 2018
Defined in header <utility>
|
||
template< class T1, class T2 > void swap( pair<T1,T2>& x, pair<T1,T2>& y ) noexcept(/* see below */); |
(since C++11) (until C++20) |
|
template< class T1, class T2 > constexpr void swap( pair<T1,T2>& x, pair<T1,T2>& y ) noexcept(/* see below */); |
(since C++20) | |
Swaps the contents of x
and y
. Equivalent to x.swap(y).
This function does not participate in overload resolution unless std::is_swappable_v<first_type> && std::is_swappable_v<second_type> is true. |
(since C++17) |
Contents |
Parameters
x, y | - | pairs whose contents to swap |
Return value
(none)
Exceptions
noexcept specification:
noexcept(noexcept(x.swap(y)))
See also
swaps the values of two objects (function template) |