std::pair (3) - Linux Manuals
std::pair: std::pair
NAME
Synopsis
Defined in header <utility>
template<
class T1,
class T2
> struct pair;
std::pair is a struct template that provides a way to store two heterogeneous objects as a single unit. A pair is a specific case of a std::tuple with two elements.
If std::is_trivially_destructible_v<T1> && std::is_trivially_destructible_v<T2> is true, the destructor of pair is trivial. (since C++17)
Template parameters
T1, T2 - the types of the elements that the pair stores.
Member types
Member type Definition
first_type T1
second_type T2
Member objects
Member name Type
first T1
second T2
Member functions
constructor (public member function)
operator= (public member function)
swap swaps the contents
(C++11)
Non-member functions
make_pair (function template)
operator==
operator!= lexicographically compares the values in the pair
operator< (function template)
operator<=
operator>
operator>=
std::swap(std::pair) specializes the std::swap algorithm
(C++11)
std::get(std::pair) accesses an element of a pair
(C++11)
Helper classes
std::tuple_size<std::pair> obtains the size of a pair
(C++11)
std::tuple_element<std::pair> obtains the type of the elements of pair
(C++11)
Deduction_guides(since C++17)
See also
tuple implements fixed size container, which holds elements of possibly different types
(C++11)
tie (function template)