22 #define QX_FLAGS_ENUM_CLASS(enumName) \
23 inline qx::flags<enumName> operator|(enumName left, enumName right) \
25 return qx::flags(left) | right; \
27 inline qx::flags<enumName> operator&(enumName left, enumName right) \
29 return qx::flags(left) & right; \
31 inline qx::flags<enumName> operator^(enumName left, enumName right) \
33 return qx::flags(left) ^ right; \
60 template<enumeration_c enum_t>
63 using underlying_type = std::underlying_type_t<enum_t>;
68 constexpr
flags() noexcept =
default;
73 constexpr
void reverse() noexcept;
79 constexpr
void shift_left(
size_t nShift) noexcept;
87 constexpr
flags operator~()
const noexcept;
89 constexpr
flags& operator<<=(
size_t nShift) noexcept;
90 constexpr
flags& operator>>=(
size_t nShift) noexcept;
92 constexpr
flags operator<<(
size_t nShift)
const noexcept;
93 constexpr
flags operator>>(
size_t nShift)
const noexcept;
102 constexpr
flags(enum_t eFlag) noexcept;
109 template<
class... args_t>
110 requires(
sizeof...(args_t) >= 2 && are_specific_v<enum_t, args_t...>)
118 template<
class... args_t>
119 requires(
sizeof...(args_t) >= 1 && are_specific_v<enum_t, args_t...>)
120 constexpr
void add(args_t...
flags) noexcept;
127 template<
class... args_t>
128 requires(
sizeof...(args_t) >= 1 && are_specific_v<enum_t, args_t...>)
136 template<
class... args_t>
137 requires(
sizeof...(args_t) >= 1 && are_specific_v<enum_t, args_t...>)
138 constexpr
void xor_(args_t...
flags) noexcept;
140 constexpr
auto operator<=>(enum_t eFlag)
const noexcept;
141 constexpr
flags& operator=(enum_t eFlag) noexcept;
143 constexpr
flags& operator|=(enum_t eFlag) noexcept;
144 constexpr
flags& operator&=(enum_t eFlag) noexcept;
145 constexpr
flags& operator^=(enum_t eFlag) noexcept;
147 constexpr
flags operator|(enum_t eFlag)
const noexcept;
148 constexpr
flags operator&(enum_t eFlag)
const noexcept;
149 constexpr
flags operator^(enum_t eFlag)
const noexcept;
153 QX_COPYMOVABLE(
flags);
173 constexpr
auto operator<=>(
const flags&)
const noexcept =
default;
175 constexpr
flags& operator|=(
flags flags_) noexcept;
176 constexpr
flags& operator&=(
flags flags_) noexcept;
177 constexpr
flags& operator^=(
flags flags_) noexcept;
179 constexpr
flags operator|(
flags flags_)
const noexcept;
180 constexpr
flags operator&(
flags flags_)
const noexcept;
181 constexpr
flags operator^(
flags flags_)
const noexcept;
190 constexpr
bool contains(enum_t eFlag)
const noexcept;
198 template<
class... args_t>
199 requires(
sizeof...(args_t) >= 2 && are_specific_v<enum_t, args_t...>)
215 template<
class... args_t>
216 requires(
sizeof...(args_t) >= 2 && are_specific_v<enum_t, args_t...>)
239 underlying_type m_EnumFlags = 0;
244 #include <qx/containers/flags.inl>
Wrapper for enumerations to be used as a list of flags.
requires(sizeof...(args_t) >=1 &&are_specific_v< enum_t, args_t... >) const expr void add(args_t... flags) noexcept
Add all the flags specified.
requires(sizeof...(args_t) >=2 &&are_specific_v< enum_t, args_t... >) const expr flags(args_t... flags) noexcept
flags object constructor
constexpr bool contains_all(flags other) const noexcept
Check if all the specified flags are present.
constexpr void remove(flags flags_) noexcept
Remove all the flags specified.
constexpr void shift_left(size_t nShift) noexcept
Shift bits to the left.
constexpr bool contains(enum_t eFlag) const noexcept
Check if flag is present.
constexpr void xor_(flags flags_) noexcept
Apply a bitwise XOR to a flags value.
constexpr bool contains_any(flags other) const noexcept
Check if any of the specified flags is present.
requires(sizeof...(args_t) >=1 &&are_specific_v< enum_t, args_t... >) const expr void xor_(args_t... flags) noexcept
Apply a bitwise XOR to a flags value.
constexpr void add(flags flags_) noexcept
Add all the flags specified.
requires(sizeof...(args_t) >=1 &&are_specific_v< enum_t, args_t... >) const expr void remove(args_t... flags) noexcept
Remove all the flags specified.
static constexpr flags all_flags() noexcept
Get a flags with all bits equal 1.
constexpr void reverse() noexcept
Reverse (or logically negotiate) all bits.
constexpr void shift_right(size_t nShift) noexcept
Shift bits to the right.
requires(sizeof...(args_t) >=2 &&are_specific_v< enum_t, args_t... >) const expr bool contains_all(args_t... flags) const noexcept
Check if all the specified flags are present.
requires(sizeof...(args_t) >=2 &&are_specific_v< enum_t, args_t... >) const expr bool contains_any(args_t... flags) const noexcept
Check if any of the specified flags is present.
constexpr underlying_type to_integer() const noexcept
Convert to the corresponding integer value.