다음을 통해 공유


get 함수 <tuple>

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

매개 변수

  • Idx
    가져올 요소의 인덱스입니다.

  • TN
    The type of the Nth tuple element.

  • tpl
    The tuple to select from.

설명

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&.

예제

 

// std_tr1__tuple__get.cpp 
// compile with: /EHsc 
#include <tuple> 
#include <iostream> 
 
typedef std::tuple<int, double, int, double> Mytuple; 
int main() 
    { 
    Mytuple c0(0, 1, 2, 3); 
 
// display contents " 0 1 2 3" 
    std::cout << " " << std::get<0>(c0); 
    std::cout << " " << std::get<1>(c0); 
    std::cout << " " << std::get<2>(c0); 
    std::cout << " " << std::get<3>(c0); 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
  

요구 사항

Header: <tuple>

네임스페이스: std

참고 항목

참조

<tuple>

tuple_element 클래스 <tuple>