std::tuple_size(std::array)
STD::元组[医]大小%28 std::数组%29
Defined in header | | |
---|---|---|
template< class T, size_t N > class tuple_size< array<T, N> > : public integral_constant<size_t, N> { }; | (1) | (since C++11) |
提供对std::array
作为编译时常量表达式。
继承自STD:积分[医]常量
成员常数
value static | N, the number of elements in the array (public static member constant) |
---|
成员函数
operator std::size_t | converts the object to std::size_t, returns value (public member function) |
---|---|
operator() (C++14) | returns value (public member function) |
成员类型
Type | Definition |
---|---|
value_type | std::size_t |
type | std::integral_constant<std::size_t, value> |
例
二次
#include <iostream>
#include <array>
template<class T>
void test(T t)
{
int a[std::tuple_size<T>::value]; // can be used at compile time
std::cout << std::tuple_size<T>::value << '\n';
}
int main()
{
std::array<float, 3> arr;
test(arr
}
二次
产出:
二次
3
二次
另见
tuple_size | obtains the size of tuple at compile time (class template specialization) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。