16template <
typename enum_type>
 
   17constexpr std::underlying_type_t<enum_type> 
to_underlying(enum_type e) { 
return static_cast<std::underlying_type_t<enum_type>
>(e); }
 
   20template <
typename enum_type>
 
   22  static constexpr bool value = 
false;
 
 
   25template <
typename enum_type>
 
   29template <
typename enum_type, std::enable_if_t<is_enum_incrementable_v<enum_type>, 
bool> = true>
 
   37template <
typename enum_type, std::enable_if_t<is_enum_incrementable_v<enum_type>, 
bool> = true>
 
   46template <
typename enum_type, std::enable_if_t<is_enum_incrementable_v<enum_type>, 
bool> = true>
 
   54template <
typename enum_type, std::enable_if_t<is_enum_incrementable_v<enum_type>, 
bool> = true>
 
   63#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type) \ 
   64  template <> struct is_enum_incrementable<enum_type> { \ 
   65    static const bool value = true; \ 
 
   69template <
typename enum_type>
 
   71  static constexpr bool value = 
false;
 
 
   74template <
typename enum_type>
 
   78template <
typename enum_type, std::enable_if_t<is_enum_sequential_v<enum_type>, 
bool> = true>
 
   79inline constexpr enum_type 
operator+(enum_type e, 
int offset)
 
 
   84template <
typename enum_type, std::enable_if_t<is_enum_sequential_v<enum_type>, 
bool> = true>
 
   85inline constexpr enum_type &operator+=(enum_type &e, 
int offset)
 
   92template <
typename enum_type, std::enable_if_t<is_enum_sequential_v<enum_type>, 
bool> = true>
 
   93inline constexpr enum_type 
operator-(enum_type e, 
int offset)
 
 
   98template <
typename enum_type, std::enable_if_t<is_enum_sequential_v<enum_type>, 
bool> = true>
 
   99inline constexpr enum_type &operator-=(enum_type &e, 
int offset)
 
  106template <
typename enum_type, std::enable_if_t<is_enum_sequential_v<enum_type>, 
bool> = true>
 
  107inline constexpr auto operator-(enum_type a, enum_type b)
 
 
  113#define DECLARE_ENUM_AS_SEQUENTIAL(enum_type) \ 
  114  template <> struct is_enum_sequential<enum_type> { \ 
  115    static const bool value = true; \ 
 
  119#define DECLARE_ENUM_AS_BIT_SET(enum_type) \ 
  120  inline constexpr enum_type operator | (enum_type m1, enum_type m2) { return static_cast<enum_type>(to_underlying(m1) | to_underlying(m2)); } \ 
  121  inline constexpr enum_type operator & (enum_type m1, enum_type m2) { return static_cast<enum_type>(to_underlying(m1) & to_underlying(m2)); } \ 
  122  inline constexpr enum_type operator ^ (enum_type m1, enum_type m2) { return static_cast<enum_type>(to_underlying(m1) ^ to_underlying(m2)); } \ 
  123  inline constexpr enum_type& operator |= (enum_type& m1, enum_type m2) { m1 = m1 | m2; return m1; } \ 
  124  inline constexpr enum_type& operator &= (enum_type& m1, enum_type m2) { m1 = m1 & m2; return m1; } \ 
  125  inline constexpr enum_type& operator ^= (enum_type& m1, enum_type m2) { m1 = m1 ^ m2; return m1; } \ 
  126  inline constexpr enum_type operator ~(enum_type m) { return static_cast<enum_type>(~to_underlying(m)); } 
 
  129#define DECLARE_ENUM_AS_ADDABLE(EnumType) \ 
  130  template <typename OtherEnumType, typename = typename std::enable_if<std::is_enum_v<OtherEnumType>, OtherEnumType>::type> \ 
  131  constexpr OtherEnumType operator + (OtherEnumType m1, EnumType m2) { \ 
  132    return static_cast<OtherEnumType>(to_underlying(m1) + to_underlying(m2)); \ 
 
  141template <
typename T, 
class = 
typename std::enable_if_t<std::is_enum_v<T>>>
 
  142debug_inline 
constexpr bool HasFlag(
const T x, 
const T y)
 
 
  152template <
typename T, 
class = 
typename std::enable_if_t<std::is_enum_v<T>>>
 
  163template <
typename Tstorage, 
typename Tenum, Tenum Tend_value>
 
  165  static constexpr Tstorage value = std::numeric_limits<Tstorage>::max() >> (std::numeric_limits<Tstorage>::digits - 
to_underlying(Tend_value));
 
 
  176template <
typename Tenum, 
typename Tstorage, Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>
 
  177class EnumBitSet : 
public BaseBitSet<EnumBitSet<Tenum, Tstorage, Tend_value>, Tenum, Tstorage, EnumBitSetMask<Tstorage, Tenum, Tend_value>::value> {
 
  192    for (
const Tenum &value : values) {
 
 
  197  constexpr auto operator <=>(
const EnumBitSet &) 
const noexcept = 
default;
 
 
Base for bitset types that accept strong types, i.e.
 
Base for bit set wrapper.
 
Tstorage data
Bitmask of values.
 
Tvalue_type ValueType
Value type of this BaseBitSet.
 
constexpr Timpl & Set()
Set all bits.
 
constexpr EnumBitSet(std::initializer_list< const Tenum > values)
Construct an EnumBitSet from a list of enum values.
 
constexpr enum_type & operator--(enum_type &e)
Prefix decrement.
 
debug_inline constexpr void ToggleFlag(T &x, const T y)
Toggle a value in a bitset enum.
 
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
 
constexpr enum_type & operator++(enum_type &e)
Prefix increment.
 
constexpr enum_type operator-(enum_type e, int offset)
Sub integer.
 
debug_inline constexpr bool HasFlag(const T x, const T y)
Checks if a value in a bitset enum is set.
 
constexpr enum_type operator+(enum_type e, int offset)
Add integer.
 
Helper template structure to get the mask for an EnumBitSet from the end enum value.
 
Trait to enable prefix/postfix incrementing operators.
 
Trait to enable prefix/postfix incrementing operators.