tuple_size Class <tuple>

Wraps tuple element count.

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

Tuple

The type of the tuple.

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

 

// 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

Header: <tuple>

Namespace: std

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft