GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::make_pair(3) C++ Standard Libary std::make_pair(3)

std::make_pair - std::make_pair


Defined in header <utility>
template< class T1, class T2 > (until C++11)
std::pair<T1,T2> make_pair( T1 t, T2 u );
template< class T1, class T2 > (since C++11)
std::pair<V1,V2> make_pair( T1&& t, T2&& u ); (until C++14)
template< class T1, class T2 > (since C++14)
constexpr std::pair<V1,V2> make_pair( T1&& t, T2&& u );


Creates a std::pair object, deducing the target type from the types of arguments.


The deduced types V1 and V2 are std::decay<T1>::type and
std::decay<T2>::type (the usual type transformations applied to
arguments of functions passed by value) unless application of (since C++11)
std::decay results in std::reference_wrapper<X> for some type X, in
which case the deduced type is X&.


t, u - the values to construct the pair from


A std::pair object containing the given values.

// Run this code


#include <iostream>
#include <utility>
#include <functional>


int main()
{
int n = 1;
int a[5] = {1, 2, 3, 4, 5};


// build a pair from two ints
auto p1 = std::make_pair(n, a[1]);
std::cout << "The value of p1 is "
<< "(" << p1.first << ", " << p1.second << ")\n";


// build a pair from a reference to int and an array (decayed to pointer)
auto p2 = std::make_pair(std::ref(n), a);
n = 7;
std::cout << "The value of p2 is "
<< "(" << p2.first << ", " << *(p2.second + 2) << ")\n";
}


The value of p1 is (1, 2)
The value of p2 is (7, 3)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.