std::meta::is_enumerable_type
From cppreference.com
| Defined in header <meta>
|
||
consteval bool is_enumerable_type( std::meta::info r );
|
(since C++26) | |
Determines if r represents a complete class type or an enum type whose list of enumerators is completely defined, or a type alias thereof.
Formally, a type T is enumerable from a point P if:
Tis a class type complete at point P orTis an enumeration type defined by a declarationDsuch thatDis reachable from P and P does not occur within an enum-specifier ofD.
Contents
Parameters
| r | - | a reflection value |
Return value
true if std::meta::dealias(r) represents a type that is enumerable from some point in the evaluation context, false otherwise
Notes
Standard reflection functions require a type to be enumerable in order to obtain its list of bases, members, or enumerators.
Example
Run this code
#include <meta>
struct A; // incomplete type
static_assert(std::meta::is_enumerable_type(^^A) == false);
struct B {}; // complete type
static_assert(std::meta::is_enumerable_type(^^B) == true);
template <typename>
struct C; // incomplete class template
static_assert(std::meta::is_enumerable_type(^^C<long>) == false);
template <>
struct C<int> {}; // complete explicit template specialization
static_assert(std::meta::is_enumerable_type(^^C<int>) == true);
template <>
struct C<long>; // incomplete explicit template specialization
static_assert(std::meta::is_enumerable_type(^^C<long>) == false);
enum class E;
static_assert(std::meta::is_enumerable_type(^^E) == false);
enum class E { e };
static_assert(std::meta::is_enumerable_type(^^E) == true);
static_assert(std::meta::is_enumerable_type(^^E::e) == false);
union U;
static_assert(std::meta::is_enumerable_type(^^U) == false);
union U { int i; short j; };
static_assert(std::meta::is_enumerable_type(^^U) == true);
int main() {}
See also
(C++26) |
checks if reflection represents a complete type (function) |