将数组的大小。
template<class Ty, std::size_t N>
class tuple_size<array<Ty, N> > {
static const unsigned value = N;
};
Template Parameters
Ty
元素的类型。N
数组大小。
备注
此模板是类模板的专用化。tuple_size 类 <tuple> 它有是整数常数表达式值为 N,该值对于数组的大小的成员 value。
示例
// 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);
}
要求
数组页眉: <>
命名空间: std