std::tuple_size<std::array>
From cppreference.com
| ヘッダー <array> で定義 |
||
| template< class T, std::size_t N > struct tuple_size< std::array<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 から継承
メンバ定数
| value [static] |
配列の要素数であるN(公開静的メンバ定数) |
メンバ関数
| operator std::size_t |
オブジェクトを std::size_t に変換し、value を返します。 (public member function) |
| operator() (C++14) |
value を返します。 (public member function) |
メンバ型
| 型 | 定義 |
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); }
[編集] 関連項目
| 構造化束縛 (C++17) | 指定された名前を初期化子のサブオブジェクトまたはタプル要素に束縛します |
| (C++11) |
タプルライクな型の要素数を取得する (クラステンプレート) |
| (C++11) |
のサイズを取得する
|
| (C++11) |
pairのサイズを取得する(クラステンプレート特殊化) |
| std::ranges::subrangeのサイズを取得する (クラステンプレート特殊化) |