std::tuple_size<std::array> - cppreference.com
来自cppreference.com
template< class T, std::size_t N > struct tuple_size< std::array<T, N> > : std::integral_constant<std::size_t, N> { }; |
(C++11 起) | |
提供作为编译时常量表达式访问 std::array 中元素数量的方法。
辅助变量模板
template< class T > constexpr std::size_t tuple_size_v = tuple_size<T>::value; |
(C++17 起) | |
继承自 std::integral_constant
成员常量
N, ,array 中的元素数 (公开静态成员常量) |
成员函数
将对象转换到 std::size_t,返回 value (公开成员函数) | |
返回 value (公开成员函数) |
成员类型
| 类型 | 定义 |
value_type
|
std::size_t
|
type
|
std::integral_constant<std::size_t, value>
|
示例
#include <array> int main() { auto arr = std::to_array("ABBA"); static_assert(std::tuple_size<decltype(arr)>{} == 5); }