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; }