10template <
typename Enum>
39 iterator
end()
const {
return {
static_cast<Underlying>(Enum::Last) + 1 }; }
45#define ENABLE_BITMASK_OPERATORS(E) \
46 template<> struct SlHelpers::hasBitmaskOperators<E> : std::true_type {}
53template<SlHelpers::BitmaskEnum E>
54constexpr E operator~(E lhs)
56 using underlying = std::underlying_type_t<E>;
57 return static_cast<E
>(~static_cast<underlying>(lhs));
60template<SlHelpers::BitmaskEnum E>
61constexpr E operator|(E lhs, E rhs)
63 using underlying = std::underlying_type_t<E>;
64 return static_cast<E
>(
static_cast<underlying
>(lhs) |
static_cast<underlying
>(rhs));
67template<SlHelpers::BitmaskEnum E>
68constexpr E operator&(E lhs, E rhs)
70 using underlying = std::underlying_type_t<E>;
71 return static_cast<E
>(
static_cast<underlying
>(lhs) &
static_cast<underlying
>(rhs));
74template<SlHelpers::BitmaskEnum E>
75constexpr E &operator|=(E &lhs, E rhs)
77 return lhs = lhs | rhs;
80template<SlHelpers::BitmaskEnum E>
81constexpr E &operator&=(E &lhs, E rhs)
83 return lhs = lhs & rhs;
86template<SlHelpers::BitmaskEnum E>
87constexpr bool hasFlag(E flags, E flag)
89 return (flags & flag) != E::NONE;
Helper class to iterate over enum values from Enum::First to Enum::Last.
Definition Enum.h:11
iterator end() const
Returns an iterator to the end of the enum range.
Definition Enum.h:39
iterator begin() const
Returns an iterator to the beginning of the enum range.
Definition Enum.h:37
std::underlying_type_t< Enum > Underlying
Type of the underlying enum values.
Definition Enum.h:14
Iterator class to iterate over enum values.
Definition Enum.h:17
Enum operator*() const
Dereference operator to get the current enum value.
Definition Enum.h:22
bool operator!=(const iterator &other) const
Inequality operator to compare two iterators.
Definition Enum.h:33
Underlying v
Current value of the iterator.
Definition Enum.h:19
iterator & operator++()
Pre-increment operator to move to the next enum value.
Definition Enum.h:25
bool operator==(const iterator &other) const
Equality operator to compare two iterators.
Definition Enum.h:31