MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Reflect::EnumByte< E > Struct Template Reference

Stores a scoped enum in its underlying integer type. More...

#include <EnumReflect.hpp>

Inheritance diagram for MayaFlux::Reflect::EnumByte< E >:
Collaboration diagram for MayaFlux::Reflect::EnumByte< E >:

Public Types

using underlying_type = std::underlying_type_t<E>

Public Member Functions

constexpr EnumByte () noexcept=default
 Holds the zero value.
constexpr EnumByte (E value) noexcept
 Stores value in its underlying integer type.
consteval EnumByte (int zero)
 Accepts the literal 0 as the empty flag set; flag enums only.
constexpr operator E () const noexcept
 Converts back to the scoped enum.

Public Attributes

underlying_type raw {}
 Underlying integer storage.

Detailed Description

template<typename E>
requires std::is_enum_v<E>
struct MayaFlux::Reflect::EnumByte< E >

Stores a scoped enum in its underlying integer type.

Use as a struct field to keep one byte per enum value while the field still accepts the scoped enum directly, so callers write .method = EnergyMethod::RMS with no cast. Reads convert back to the scoped enum implicitly. Integers do not convert to the wrapper, so an out-of-range or wrong-family value cannot be stored by accident.

For a flag enum, one declared with MF_BITMASK_OPERATORS, the literal 0 also converts and means no flags, so .mods = 0 stays valid. Any other integer, and any non-constant integer, is a compile error.

Template Parameters
EA scoped enumeration type.

Definition at line 200 of file EnumReflect.hpp.


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