107 static_assert(std::is_enum_v<EnumType>,
"EnumFlags can only be used with enum types");
110 using Type = std::underlying_type_t<EnumType>;
112 constexpr EnumFlags(Type value = Type{0}) :
113 g_flags(
static_cast<Type
>(value))
116 EnumFlags& set(Type flag)
118 this->g_flags |=
static_cast<Type
>(flag);
121 EnumFlags& unset(Type flag)
123 this->g_flags &= ~static_cast<Type>(flag);
126 EnumFlags& toggle(Type flag)
128 this->g_flags ^=
static_cast<Type
>(flag);
132 [[nodiscard]]
constexpr bool has(Type flag)
const {
return (this->g_flags &
static_cast<Type
>(flag)) == flag; }
134 [[nodiscard]]
constexpr Type get()
const {
return this->g_flags; }
135 constexpr EnumFlags& operator=(Type value)
137 this->g_flags = value;