std::tuple_size(std::array) - cppreference.com
提供: cppreference.com
<tbody> </tbody>
|
|
(C++11以上) | |
コンパイル時定数式として std::array 内の要素の数へのアクセスを提供します。
std::integral_constant から継承
メンバ定数
N、配列内の要素の数 (パブリック静的メンバ定数) |
メンバ関数
オブジェクトを std::size_t に変換します。 value を返します (パブリックメンバ関数) | |
value を返します (パブリックメンバ関数) |
メンバ型
| 型 | 定義 |
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); }
出力: