pair [C++ Reference]
Keywords: stl,utility,pair
Date: 2009-10-17T23:52:43-0700

[[pair]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## pair

Syntax:

      pair();
      pair( const T1 &a, const T2 &b );

The pair struct is a way to store two pieces of heterogeneous data.

These data may be accessed using the `first` and `second` fields of a pair.

Pairs may be tested for equality with the `==` operator. The `<` operator is also defined for pairs; given two pairs `x` and `y`, the `<` operator returns:

    x.first < y.first || ((y.first == x.first) && x.second < y.second)

The make_pair function can be used as a shortcut when creating pairs to avoid explicitly specifying the types for the two pieces of data.

Related: make_pair

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •