Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::_::enum_reflection< E, Handler > Struct Template Reference

Provide utilities for enum reflection. More...

#include <enum.hpp>

Public Types

using U = underlying_type_t<E>
 
using UU = typename std::make_unsigned<U>::type
 

Static Public Member Functions

template<U Low, U High, typename... Args>
static constexpr U each_enum_range (U last_value, Args &... args)
 Iterate over the range [Low, High] of enum values between Low and High.
 
template<U Low, U High, typename... Args>
static constexpr U each_mask_range (U last_value, Args &... args)
 Iterate over the mask range (Low, High] of enum values between Low and High.
 
template<U Value = static_cast<U>(_::to_constant< E , 126>::value), typename... Args>
static constexpr U each_enum (Args &... args)
 Handle enum iteration for gathering reflection data.
 

Static Public Attributes

static const U high_bit
 

Detailed Description

template<typename E, typename Handler>
struct flecs::_::enum_reflection< E, Handler >

Provide utilities for enum reflection.

This struct provides static functions for enum reflection, including conversion between enum values and their underlying integral types, and iteration over enum values.

Template Parameters
EThe enum type.
HandlerThe handler for enum reflection operations.

Definition at line 232 of file enum.hpp.

Member Typedef Documentation

◆ U

template<typename E , typename Handler >
using flecs::_::enum_reflection< E, Handler >::U = underlying_type_t<E>

Definition at line 233 of file enum.hpp.

◆ UU

template<typename E , typename Handler >
using flecs::_::enum_reflection< E, Handler >::UU = typename std::make_unsigned<U>::type

Definition at line 312 of file enum.hpp.

Member Function Documentation

◆ each_enum()

template<typename E , typename Handler >
template<U Value = static_cast<U>(_::to_constant< E , 126>::value), typename... Args>
static constexpr U flecs::_::enum_reflection< E, Handler >::each_enum ( Args &... args)
inlinestaticconstexpr

Handle enum iteration for gathering reflection data.

Iterate over all enum values up to a specified maximum value (each_enum_range<0, Value>), then iterate over the rest of the possible bitmasks (each_mask_range<Value, high_bit>).

Template Parameters
ValueThe maximum enum value to iterate up to.
ArgsAdditional arguments to be passed through to Handler::handle_constant().
Parameters
argsAdditional arguments to be passed through to Handler::handle_constant().
Returns
constexpr U The result of the iteration.

Definition at line 306 of file enum.hpp.

◆ each_enum_range()

template<typename E , typename Handler >
template<U Low, U High, typename... Args>
static constexpr U flecs::_::enum_reflection< E, Handler >::each_enum_range ( U last_value,
Args &... args )
inlinestaticconstexpr

Iterate over the range [Low, High] of enum values between Low and High.

Recursively divide and conquer the search space to reduce the template depth. Once recursive division is complete, call Handler::handle_constant() in ascending order, passing the values computed up the chain.

Template Parameters
LowThe lower bound of the search range, inclusive.
HighThe upper bound of the search range, inclusive.
ArgsAdditional arguments to be passed through to Handler::handle_constant().
Parameters
last_valueThe last value processed in the iteration.
argsAdditional arguments to be passed through to Handler::handle_constant().
Returns
constexpr U The result of the iteration.

Definition at line 252 of file enum.hpp.

◆ each_mask_range()

template<typename E , typename Handler >
template<U Low, U High, typename... Args>
static constexpr U flecs::_::enum_reflection< E, Handler >::each_mask_range ( U last_value,
Args &... args )
inlinestaticconstexpr

Iterate over the mask range (Low, High] of enum values between Low and High.

Recursively iterate the search space, looking for enums defined as multiple-of-2 bitmasks. Each iteration shifts the bit to the right until it hits Low, then calls Handler::handle_constant() for each bitmask in ascending order.

Template Parameters
LowThe lower bound of the search range, not inclusive.
HighThe upper bound of the search range, inclusive.
ArgsAdditional arguments to be passed through to Handler::handle_constant().
Parameters
last_valueThe last value processed in the iteration.
argsAdditional arguments to be passed through to Handler::handle_constant().
Returns
constexpr U The result of the iteration.

Definition at line 282 of file enum.hpp.

Member Data Documentation

◆ high_bit

template<typename E , typename Handler >
const U flecs::_::enum_reflection< E, Handler >::high_bit
static
Initial value:
=
static_cast<U>(static_cast<UU>(1) << (sizeof(UU) * 8 - 1))

Definition at line 313 of file enum.hpp.


The documentation for this struct was generated from the following file: