首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::variant_alternative_t

Defined in header <variant>

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 <size_t I, class T> using variant_alternative_t = typename variant_alternative<I, T>::type;

(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)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券