11 template <
typename Enum>
12 requires std::is_enum_v<Enum>
19 EnumRange() requires requires { Enum::First; Enum::Last; }
82 #define ENABLE_BITMASK_OPERATORS(E) \ 83 template<> struct SlHelpers::hasBitmaskOperators<E> : std::true_type {} 90 template<SlHelpers::BitmaskEnum E>
91 constexpr E operator~(E lhs)
93 using underlying = std::underlying_type_t<E>;
94 return static_cast<E
>(~static_cast<underlying>(lhs));
97 template<SlHelpers::BitmaskEnum E>
98 constexpr E operator|(E lhs, E rhs)
100 using underlying = std::underlying_type_t<E>;
101 return static_cast<E
>(
static_cast<underlying
>(lhs) | static_cast<underlying>(rhs));
104 template<SlHelpers::BitmaskEnum E>
105 constexpr E operator&(E lhs, E rhs)
107 using underlying = std::underlying_type_t<E>;
108 return static_cast<E
>(
static_cast<underlying
>(lhs) & static_cast<underlying>(rhs));
111 template<SlHelpers::BitmaskEnum E>
112 constexpr E &operator|=(E &lhs, E rhs)
114 return lhs = lhs | rhs;
117 template<SlHelpers::BitmaskEnum E>
118 constexpr E &operator&=(E &lhs, E rhs)
120 return lhs = lhs & rhs;
123 template<SlHelpers::BitmaskEnum E>
124 constexpr
bool hasFlag(E flags, E flag)
126 return (flags & flag) != E::NONE;
Enum value_type
Type of the enum values in the range.
Definition: Enum.h:66
std::underlying_type_t< Enum > Underlying
Type of the underlying enum values.
Definition: Enum.h:16
Enum * pointer
Pointer type for the enum range.
Definition: Enum.h:38
bool operator!=(const iterator &other) const
Inequality operator to compare two iterators.
Definition: Enum.h:62
std::ptrdiff_t difference_type
Difference type for the enum range.
Definition: Enum.h:32
Enum value_type
Value type for the enum range.
Definition: Enum.h:34
std::forward_iterator_tag iterator_category
Iterator category for the enum range.
Definition: Enum.h:30
Enum operator*() const
Dereference operator to get the current enum value.
Definition: Enum.h:44
iterator begin() const
Returns an iterator to the beginning of the enum range.
Definition: Enum.h:71
iterator operator++(int)
Post-increment operator to move to the next enum value.
Definition: Enum.h:53
Helper class to iterate over enum values from Enum::First to Enum::Last.
Definition: Enum.h:13
Underlying v
Current value of the iterator.
Definition: Enum.h:41
iterator end() const
Returns an iterator to the end of the enum range.
Definition: Enum.h:73
Iterator class to iterate over enum values.
Definition: Enum.h:28
bool operator==(const iterator &other) const
Equality operator to compare two iterators.
Definition: Enum.h:60
Enum reference
Reference type for the enum range.
Definition: Enum.h:36
EnumRange() requires requires
Constructs an EnumRange from Enum::First to Enum::Last.
Definition: Enum.h:19
iterator & operator++()
Pre-increment operator to move to the next enum value.
Definition: Enum.h:47