Export (0) Print
Expand All

tuple_size Class <array>

Wraps the size of an array.

template<class Ty, std::size_t N>
class tuple_size<array<Ty, N> > {
    static const unsigned value = N;
    };

Ty

The type of an element.

N

The size of the array.

This template is a specialization of the template class tuple_size Class <tuple>. It has a member value that is an integral constant expression whose value is N, which is the size of the array.

 

// std_tr1__array__tuple_size.cpp 
// compile with: /EHsc 
#include <array> 
#include <iostream> 
 
typedef std::array<int, 4> Myarray; 
int main() 
    { 
    Myarray c0 = {0, 1, 2, 3}; 
 
// display contents " 0 1 2 3" 
    for (Myarray::const_iterator it = c0.begin(); 
        it != c0.end(); ++it) 
        std::cout << " " << *it; 
    std::cout << std::endl; 
 
// display size " 4" 
    std::cout << " " << std::tuple_size<Myarray>::value; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1 2 3
 4

Header: <array>

Namespace: std

Show:
© 2014 Microsoft