make_pair [C++ Reference]
Keywords: stl,utility,make_pair
Date: 2008-10-14T15:42:10-0700

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

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## make_pair

Syntax:

      pair<TYPE1,TYPE2> make_pair( const TYPE1 &a, const TYPE2 &b );

The make_pair function returns a single object that contains the two items `a` and `b`. make_pair is a quick way of creating an instance of the pair class.

For example:

    #include <string>
    using std::string;
    #include <iostream>
    using std::cout;
    #include <utility>
    using std::pair;
    using std::make_pair;

    int main () {
      pair<int,string> tuple = make_pair( 42, "The answer" );

      cout << "tuple.first: " << tuple.first
           << ", tuple.second: " << tuple.second << '\n';

      return 0;
    }

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