Share via


tuple_size Class <tuple>

Wraps tuple element count.

template<class Tuple>
class tuple_size {
    static const unsigned value = ...;
    };

Parameters

  • Tuple
    The type of the tuple.

Remarks

The template class has a member value that is an integral constant expression whose value is the extent of the tuple type Tuple.

Example

 

// std_tr1__tuple__tuple_size.cpp 
// compile with: /EHsc 
#include <tuple> 
#include <iostream> 
#include <utility> 
 
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; 
 
// display size " 4" 
    std::cout << " " << std::tuple_size<Mytuple>::value; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1 2 3
 4

Requirements

Header: <tuple>

Namespace: std

See Also

Reference

<tuple>

tuple Class

tuple_element Class <tuple>

Other Resources

<tuple> Members