Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Gets an element from a tuple object.
template<int Idx, class T1, class T2, ..., class TN>
RI get(tuple<T1, T2, ..., TN>& tpl);
template<int Idx, class T1, class T2, ..., class TN>
RI get(const tuple<T1, T2, ..., TN>& tpl);
Parameters
Idx
The index of the element to get.TN
The type of the Nth tuple element.tpl
The tuple to select from.
Remarks
The template functions return a reference to the value at index Idx in the tuple object tpl. If the corresponding type Ui is a reference type both functions return Ui; otherwise the first function returns Ui& and the second function returns const Ui&.
Example
// std_tr1__tuple__get.cpp
// compile with: /EHsc
#include <tuple>
#include <iostream>
typedef std::tr1::tuple<int, double, int, double> Mytuple;
int main()
{
Mytuple c0(0, 1, 2, 3);
// display contents " 0 1 2 3"
std::cout << " " << std::tr1::get<0>(c0);
std::cout << " " << std::tr1::get<1>(c0);
std::cout << " " << std::tr1::get<2>(c0);
std::cout << " " << std::tr1::get<3>(c0);
std::cout << std::endl;
return (0);
}
0 1 2 3
Requirements
Header: <tuple>
Namespace: std::tr1