std::swap(std::pair)

From cppreference.com
< cpp‎ | utility‎ | pair
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

Elementary string conversions
(C++17)
(C++17)
 
std::pair
Member functions
Non-member functions
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
std::swap
(C++11)
Deduction guides(C++17)
Helper classes
(C++11)
 
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)

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)