std::tuple_size<std::array>
來自 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 [靜態] |
N ,陣列中的元素數量(public static 成員常量) |
成員函式
operator std::size_t |
將物件轉換為 std::size_t,返回 value (公開成員函式) |
operator() (C++14) |
返回 value (公開成員函式) |
成員型別
型別 | 定義 |
value_type
|
std::size_t |
型別
|
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) |
獲取 tuple 的大小一個 |
(C++11) |
獲取 pair 的大小(類模板特化) |
獲取 std::ranges::subrange 的大小 (類模板特化) |