Namespaces
Variants

std::meta::is_enumerable_type

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Reflection queries
Reflection layout queries
Type properties
Type property queries
 
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:

  • T is a class type complete at point P or
  • T is an enumeration type defined by a declaration D such that D is reachable from P and P does not occur within an enum-specifier of D.

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

#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

checks if reflection represents a complete type
(function) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.