utility/tuple") (C++11)  
[ optional  ](/w/cpp/utility/optional "cpp/utility/optional") (C++17)  
[ any  ](/w/cpp/utility/any "cpp/utility/any") (C++17)  
[ variant  ](/w/cpp/utility/variant "cpp/utility/variant") (C++17)  
  
|  [ tuple_size  ](/w/cpp/utility/tuple_size "cpp/utility/tuple size") (C++11)  
---  
[ tuple_element  ](/w/cpp/utility/tuple_element "cpp/utility/tuple element")
(C++11)  
[ apply  ](/w/cpp/utility/apply "cpp/utility/apply") (C++17)  
[ make_from_tuple  ](/w/cpp/utility/make_from_tuple "cpp/utility/make from
tuple") (C++17)  
[ expected  ](/w/cpp/utility/expected "cpp/utility/expected") (C++23)  
  
[ Elementary string conversions ](/w/cpp/utility#Elementary_string_conversions
"cpp/utility")  
|  [ to_chars  ](/w/cpp/utility/to_chars "cpp/utility/to chars") (C++17)  
---  
[ from_chars  ](/w/cpp/utility/from_chars "cpp/utility/from chars") (C++17)  
[ chars_format  ](/w/cpp/utility/chars_format "cpp/utility/chars format")
(C++17)  
  
|  [ to_chars_result  ](/w/cpp/utility/to_chars_result "cpp/utility/to chars
result") (C++17)  
---  
[ from_chars_result  ](/w/cpp/utility/from_chars_result "cpp/utility/from
chars result") (C++17)  
  
  
  
  
  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/navbar_content&action=edit)

**` std::pair ` **

Member functions  
---  
[ pair::pair  ](/w/cpp/utility/pair/pair "cpp/utility/pair/pair")  
[ pair::operator=  ](/w/cpp/utility/pair/operator%3D
"cpp/utility/pair/operator=")  
[ pair::swap  ](/w/cpp/utility/pair/swap "cpp/utility/pair/swap") (C++11)  
Non-member functions  
[ make_pair  ](/w/cpp/utility/pair/make_pair "cpp/utility/pair/make pair")  
[ operator==  operator!=  operator< operator<=  operator> operator>=
operator<=> ](/w/cpp/utility/pair/operator_cmp "cpp/utility/pair/operator
cmp") (until C++20)  (until C++20)  (until C++20)  (until C++20)  (until
C++20)  (C++20)  
[ swap  (std::pair)  ](/w/cpp/utility/pair/swap2 "cpp/utility/pair/swap2")
(C++11)  
[ get  (std::pair)  ](/w/cpp/utility/pair/get "cpp/utility/pair/get") (C++11)  
[ Deduction guides ](/w/cpp/utility/pair/deduction_guides
"cpp/utility/pair/deduction guides") (C++17)  
Helper classes  
[ tuple_size  <std::pair> ](/w/cpp/utility/pair/tuple_size
"cpp/utility/pair/tuple size") (C++11)  
[ tuple_element  <std::pair> ](/w/cpp/utility/pair/tuple_element
"cpp/utility/pair/tuple element") (C++11)  
[ basic_common_reference  <std::pair>
](/w/cpp/utility/pair/basic_common_reference "cpp/utility/pair/basic common
reference") (C++23)  
[ common_type  <std::pair> ](/w/cpp/utility/pair/common_type
"cpp/utility/pair/common type") (C++23)  
[ formatter  <std::pair> ](/w/cpp/utility/format/tuple_formatter
"cpp/utility/format/tuple formatter") (C++23)  
[ piecewise_construct_t  ](/w/cpp/utility/piecewise_construct
"cpp/utility/piecewise construct") (C++11)  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/pair/navbar_content&action=edit)

Defined in header ` [ <utility> ](/w/cpp/header/utility "cpp/header/utility") ` |  |   
---|---|---  
template  <  
class  T1,  
class  T2  
> struct  pair  ;  |  |   
|  |   
  
` std::pair ` is a class template that provides a way to store two
heterogeneous objects as a single unit. A pair is a specific case of a  [
std::tuple ](/w/cpp/utility/tuple "cpp/utility/tuple") with two elements.

If neither ` T1 ` nor ` T2 ` is a possibly cv-qualified class type with non-
trivial destructor, or array thereof, the destructor of ` pair ` is trivial.

##  Contents

  * 1  Template parameters 
  * 2  Member types 
  * 3  Member objects 
  * 4  Member functions 
  * 5  Non-member functions 
  * 6  Helper classes 
  * 7  Deduction guides  (since C++17) 
  * 8  Defect reports 
  * 9  See also 

  
---  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/utility/pair&action=edit&section=1
"Edit section: Template parameters") ]  Template parameters

T1, T2  |  \-  |  the types of the elements that the pair stores.