std::meta::variant_size
From cppreference.com
| Defined in header <meta>
|
||
consteval std::size_t variant_size( std::meta::info r );
|
(since C++26) | |
Returns the number of alternatives in a reflected (possibly cv-qualified) variant type represented by reflection r.
Equivalent to std::variant_size<T>::value, where T is the type represented by std::meta::dealias(r).
Parameters
| r | - | a reflection value |
Return value
The size of reflected variant type.
Exceptions
Throws std::meta::exception if r does not represent a type or type alias.
Example
Run this code
#include <meta>
#include <variant>
static_assert
(
std::meta::variant_size(^^std::variant<>) == 0 and
std::meta::variant_size(^^std::variant<std::variant<>>) == 1 and
std::meta::variant_size(^^std::variant<char, int>) == 2 and
std::meta::variant_size(^^std::variant<int, char, float>) == 3 and
"");
int main() {}
