std::variant_alternative
性病:变体[医]备选案文,STD::变式[医]替代[医]T型
Defined in header | | |
---|---|---|
template <std::size_t I, class T> struct variant_alternative; /* undefined */ | (1) | (since C++17) |
template <size_t I, class... Types> struct variant_alternative<I, variant<Types...>>; | (2) | (since C++17) |
template <size_t I, class T> class variant_alternative<I, const T>; template <size_t I, class T> class variant_alternative<I, volatile T>; template <size_t I, class T> class variant_alternative<I, const volatile T>; | (3) | (since C++17) |
提供编译时索引访问可能的cv限定变体的类型,并结合变体%28的cv-资格(如果有%29)和备选版本的cv-资格。
正式的,
2%29TransformationTrait
成员类型的要求ftype
等于索引的替代类型。I
3%29TransformationTrait成员类型的要求ftype他们的名字,分别,std::add_const_t<std::variant_alternative<I,T>>,,,std::add_volatile_t<std::variant_alternative<I,T>>,和std::add_cv_t<std::variant_alternative<I,T>>
成员类型
Member type | Definition |
---|---|
type | the type of Ith alternative of the variant, where I must be in [0, sizeof...(Types)), otherwise the behavior is undefined |
辅助模板别名
template | | (since C++17) |
---|
例
另见
variant_sizevariant_size_v (C++17) | obtains the size of the variant's list of alternatives at compile time (class template) (variable template) |
---|---|
tuple_element | obtains the type of the specified element (class template specialization) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。