StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
Enumeration concepts

Concepts and helpers for enum / enum class types. More...

Concepts

concept  StormByte::Type::Enum
 Unscoped or scoped enumeration (enum / enum class).
concept  StormByte::Type::UnsignedEnum
 StormByte::Type::Enum whose underlying type is unsigned.
concept  StormByte::Type::ScopedEnum
 Scoped enumeration (enum class / enum struct).

Helpers

template<typename E>
using StormByte::Type::UnderlyingType = std::underlying_type_t<std::remove_cv_t<E>>
 Underlying integer type of enumeration E.
template<typename E>
requires Enum<E>
constexpr UnderlyingType< E > StormByte::Type::ToUnderlying (E e) noexcept
 Converts an enumeration value to its underlying integer.

Detailed Description

Concepts and helpers for enum / enum class types.

Typedef Documentation

◆ UnderlyingType

template<typename E>
using StormByte::Type::UnderlyingType = std::underlying_type_t<std::remove_cv_t<E>>

Underlying integer type of enumeration E.

Template Parameters
EEnumeration type satisfying StormByte::Type::Enum.
enum class Foo : uint16_t { A };
std::underlying_type_t< std::remove_cv_t< E > > UnderlyingType
Underlying integer type of enumeration E.
Definition enums.hxx:123

Function Documentation

◆ ToUnderlying()

template<typename E>
requires Enum<E>
UnderlyingType< E > StormByte::Type::ToUnderlying ( E e)
constexprnoexcept

Converts an enumeration value to its underlying integer.

Template Parameters
EEnumeration type satisfying StormByte::Type::Enum.
Parameters
[in]eValue to convert.
Returns
Underlying integer representation of e.
enum class Foo : int { A = 3 };
auto n = Type::ToUnderlying(Foo::A); // 3
constexpr UnderlyingType< E > ToUnderlying(E e) noexcept
Converts an enumeration value to its underlying integer.
Definition enums.hxx:138