Delen via


tuple_element Class <utility>

Wraps the type of a pair element.

template<class T1, class T2>  
    class tuple_element<0, pair<T1, T2> > {
    typedef T1 type;
    };
template<class T1, class T2>
    class tuple_element<1, pair<T1, T2> > {
    typedef T2 type;
    };

Parameters

  • T1
    The type of the first pair elemment.

  • T2
    The type of the second pair elemment.

Remarks

The templates are specializations of the template class tuple_element Class <tuple>. Each has a nested typedef type that is a synonym for the type of the corresponding pair element.

Example

 

// std_tr1__utility__tuple_element.cpp 
// compile with: /EHsc 
#include <utility> 
#include <iostream> 
 
typedef std::pair<int, double> Mypair; 
int main() 
    { 
    Mypair c0(0, 1); 
 
// display contents " 0 1" 
    std::cout << " " << std::get<0>(c0); 
    std::cout << " " << std::get<1>(c0); 
    std::cout << std::endl; 
 
// display first element " 0" 
    std::tuple_element<0, Mypair>::type val = std::get<0>(c0); 
    std::cout << " " << val; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1
 0

Requirements

Header: <utility>

Namespace: std

See Also

Reference

get Function <utility>

tuple_size Class <utility>