C++ Array 库 - tuple_size() 函数
描述
C++ 函数 std::tuple_size(std::array) 返回容器中存在的元素总数。
声明
以下是 std::tuple_size(std::array) 函数形式 std::array 头的声明。
template< class T, size_t N >
class tuple_size< array<T, N> > :
public integral_constant≶size_t, N>
{ };
参数
T − 获取元组大小的类型。
示例
以下示例显示了 std::tuple_size(std::array) 函数的用法。
#include <iostream>
#include <array>
using namespace std;
int main(void) {
typedef array<int, 4> arr;
cout << "Size = " << tuple_size<arr>::value << endl;
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 −
Size = 4

