Files
2025-10-25 03:02:53 +03:00

2.4 KiB
Raw Permalink Blame History

[variant.helper]

22 General utilities library [utilities]

22.6 Variants [variant]

22.6.4 variant helper classes [variant.helper]

🔗

template<class T> struct variant_size;

1

#

All specializations of variant_size meet theCpp17UnaryTypeTrait requirements ([meta.rqmts]) with a base characteristic of integral_constant<size_t, N> for some N.

🔗

template<class T> struct variant_size<const T>;

2

#

Let VS denote variant_size of the cv-unqualified type T.

Then each specialization of the template meets theCpp17UnaryTypeTrait requirements ([meta.rqmts]) with a base characteristic of integral_constant<size_t, VS::value>.

🔗

template<class... Types> struct variant_size<variant<Types...>> : integral_constant<size_t, sizeof...(Types)> { };

🔗

template<size_t I, class T> struct variant_alternative<I, const T>;

3

#

Let VA denote variant_alternative<I, T> of the cv-unqualified type T.

Then each specialization of the template meets the Cpp17TransformationTrait requirements ([meta.rqmts]) with a member typedef type that names the type add_const_t<VA::type>.

🔗

variant_alternative<I, variant<Types...>>::type

4

#

Mandates: I < sizeof...(Types).

5

#

Type: The type TI.