std::variant_size,std::variant_size_v (3) - Linux Manuals
std::variant_size,std::variant_size_v: std::variant_size,std::variant_size_v
NAME
std::variant_size,std::variant_size_v - std::variant_size,std::variant_size_v
Synopsis
Defined in header <variant>
template <class T> (1) (since C++17)
struct variant_size; /* undefined */
template <class... Types>
struct variant_size<std::variant<Types...>> (2) (since C++17)
: std::integral_constant<std::size_t, sizeof...(Types)> { };
template <class T> class variant_size<const T>;
template <class T> class variant_size<volatile T>; (3) (since C++17)
template <class T> class variant_size<const volatile T>;
Provides access to the number of alternatives in a possibly cv-qualified variant as a compile-time constant expression.
Formally,
2) meets the UnaryTypeTrait requirements with a BaseCharacteristic of std::integral_constant<std::size_t, sizeof...(Types)>
3) meets the UnaryTypeTrait requirements with a BaseCharacteristic of std::integral_constant<std::size_t, variant_size<T>>
Helper variable template
template <class T> (since C++17)
inline constexpr std::size_t variant_size_v = std::variant_size<T>::value;
Inherited from std::integral_constant
Member constants
value sizeof...(Types)
[static]
Member functions
operator std::size_t (public member function)
operator() returns value
(C++14)
Member types
Type Definition
value_type std::size_t
type std::integral_constant<std::size_t, value>
Notes
All specializations of std::variant_size satisfy UnaryTypeTrait with BaseCharacteristic std::integral_constant<std::size_t, N> for some N.
Example
This section is incomplete
Reason: no example
See also
variant_alternative obtains the type of the alternative specified by its index, at compile time
variant_alternative_t (class template) (alias template)
(C++17)
tuple_size (class template specialization)