CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 23 Jul 2025 09:24:11 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/utility/make_pair/
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 23 Jul 2025 09:24:11 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"6c93-OfVE8afLbgBbqHQJ/whexP0dWW4"
Content-Encoding: gzip
Constructs a pair object with its first element set to x and its second element set to y.
The template types can be implicitly deduced from the arguments passed to make_pair.
pair objects can be constructed from other pair objects containing different types, if the respective types are implicitly convertible.
The template parameters can be implicitly deduced.
Output:
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<utility>
classes
functions
types
-
piecewise_construct_tC++11
-
constants
-
piecewise_constructC++11
-
namespaces
function template
<utility>
std::make_pair
template <class T1, class T2> pair<T1,T2> make_pair (T1 x, T2 y);
template <class T1, class T2> pair<V1,V2> make_pair (T1&& x, T2&& y); // see below for definition of V1 and V2
Construct pair object
The template types can be implicitly deduced from the arguments passed to make_pair.
pair objects can be constructed from other pair objects containing different types, if the respective types are implicitly convertible.
The behavior of this function template is the same as if defined as:
|
|
The function returns:
Where the types V1 and V2 are the decay equivalents of T1 and T2, respectively (except for reference_wrapper types, for which the corresponding reference type is used instead).
If T1 and/or T2 are rvalue references, the objects are moved and x and/or y are left in an undefined but valid state.
|
|
If T1 and/or T2 are rvalue references, the objects are moved and x and/or y are left in an undefined but valid state.
Parameters
- x, y
- Values for the members first and second, respectively, of the pair object being constructed.
Return value
A pair object whose elements first and second are set to x and y respectivelly.The template parameters can be implicitly deduced.
Example
|
|
Output:
foo: 10, 20 bar: 10, 65 |
Data races
If either (or both) T1 or T2 is an rvalue reference type of a type supporting move semantics, its corresponding argument is modified.Exception safety
The function provides the same level of guarantees to each object as provided by the corresponding element constructor.See also
- pair::pair
- Construct pair (public member function)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us