std::variant_size
性病:变体[医]大小,STD::变体[医]大小[医]v型
Defined in header | | |
---|---|---|
template <class T> struct variant_size; /* undefined */ | (1) | (since C++17) |
template <class... Types> struct variant_size<std::variant<Types...>> : std::integral_constant<std::size_t, sizeof...(Types)> { }; | (2) | (since C++17) |
template <class T> class variant_size<const T>; template <class T> class variant_size<volatile T>; template <class T> class variant_size<const volatile T>; | (3) | (since C++17) |
以编译时常量表达式的形式提供对可能的cv限定变量中的替代方案的访问。
正式的,
2%29UnaryTypeTrait具有基本特征的需求std::integral_constant<std::size_t, sizeof...(Types)>
3%29UnaryTypeTrait具有基本特征的需求std::integral_constant<std::size_t, variant_size<T>>
辅助变量模板
template | | (since C++17) |
---|
继承自STD:积分[医]常量
成员常数
value static | sizeof...(Types) (public static member constant) |
---|
成员函数
operator std::size_t | converts the object to std::size_t, returns value (public member function) |
---|---|
operator() (C++14) | returns value (public member function) |
成员类型
Type | Definition |
---|---|
value_type | std::size_t |
type | std::integral_constant<std::size_t, value> |
注记
所有的专门化std::variant_size满足感UnaryTypeTrait带着基本特征std::integral_constant<std::size_t, N>对一些人来说N...
例
另见
variant_alternativevariant_alternative_t (C++17) | obtains the type of the alternative specified by its index, at compile time (class template) (alias template) |
---|---|
tuple_size | obtains the size of tuple at compile time (class template specialization) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。