共用方式為


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

Template Parameters

  • Ty
    The type of an element.

  • N
    The size of the array.

Remarks

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.

Example

 

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

Requirements

Header: <array>

Namespace: std

See Also

Reference

<array>

<tuple>

tuple_size Class <tuple>