std::pair<T1,T2>::swap (3) - Linux Manuals
std::pair<T1,T2>::swap: std::pair<T1,T2>::swap
NAME
std::pair<T1,T2>::swap - std::pair<T1,T2>::swap
Synopsis
void swap(pair& other) noexcept(/* see below */); (since C++11)
constexpr void swap(pair& other) noexcept(/* see below */); (since C++20)
Swaps first with other.first and second with other.second.
Parameters
other - pair of values to swap
Return value
(none)
Exceptions
noexcept specification:
noexcept(
noexcept(swap(first, other.first)) && (until C++17)
noexcept(swap(second, other.second))
)
In the expression above, the identifier swap is looked up in the same manner as the one used by the C++17 std::is_nothrow_swappable trait.
noexcept specification:
noexcept(
std::is_nothrow_swappable_v<first_type> && (since C++17)
std::is_nothrow_swappable_v<second_type>
)
Example
// Run this code
Output:
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
LWG_2456 C++11 the noexcept specification is ill-formed made to work
See also
swap (function template)