105 static_assert(std::is_enum_v<EnumType>,
"EnumFlags can only be used with enum types");
108 using Type = std::underlying_type_t<EnumType>;
110 constexpr EnumFlags(Type value = Type{0}) :
111 g_flags(
static_cast<Type
>(value))
114 EnumFlags& set(Type flag)
116 this->g_flags |=
static_cast<Type
>(flag);
119 EnumFlags& unset(Type flag)
121 this->g_flags &= ~static_cast<Type>(flag);
124 EnumFlags& toggle(Type flag)
126 this->g_flags ^=
static_cast<Type
>(flag);
130 [[nodiscard]]
constexpr bool has(Type flag)
const {
return (this->g_flags &
static_cast<Type
>(flag)) == flag; }
132 [[nodiscard]]
constexpr Type get()
const {
return this->g_flags; }
133 constexpr EnumFlags& operator=(Type value)
135 this->g_flags = value;