CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 23 Jul 2025 15:56:49 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/utility/pair/get/
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 23 Jul 2025 15:56:49 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"7283-8j8mLamaHMRz9svOy+2iC/GXN/0"
Content-Encoding: gzip
Returns a reference to member first if I is
This overload of tuple's homonym function get is provided so that pair objects can be treated as a tuples. For that purpose, header
For rvalue pair objects (2), the function returns an rvalue reference (as if forward was used).
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
pair
- pair::pair
member functions
- pair::operator=
-
pair::swapC++11
non-member overloads
-
get (pair)C++11
- relational operators (pair)
-
swap (pair)C++11
-
non-member specializations
-
tuple_element<pair>C++11
-
tuple_size<pair>C++11
-
function template
<utility>
std::get (pair)
lvalue (1) | template <size_t I, class T1, class T2> typename tuple_element< I, pair<T1,T2> >::type& get (pair<T1,T2>& pr) noexcept; |
---|---|
rvalue (2) | template <size_t I, class T1, class T2> typename tuple_element< I, pair<T1,T2> >::type&& get (pair<T1,T2>&& pr) noexcept; |
const (3) | template <size_t I, class T1, class T2> const typename tuple_element< I, pair<T1,T2> >::type& get (const pair<T1,T2>& pr) noexcept; |
Get element (tuple interface)
0
, or a reference to member second if I is 1
.This overload of tuple's homonym function get is provided so that pair objects can be treated as a tuples. For that purpose, header
<utility>
also overloads tuple_size and tuple_element types with the appropriate members defined.Template parameters
- I
- Position of an element in the pair, with
0
identifying member first, and1
identifying member second.
size_t is an unsigned integral type. - T1, T2
- Type of the elements in the pair.
Function parameters
- pr
- A pair object.
Return value
A reference to a member of the pair.For rvalue pair objects (2), the function returns an rvalue reference (as if forward was used).
Example
|
|
Output:
foo contains: 50 and x |
Data races
One of the members of pr is potentially accessed or modified by the caller. Concurrently accessing the other is safe.Exception safety
No-throw guarantee: this function never throws exceptions.See also
- get (tuple)
- Get element (function template)
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