21template <
typename T,
typename E>
22 requires(std::is_enum_v<E> && std::is_integral_v<T>)
48 template <
typename... Es>
49 requires(std::is_same_v<Es, E> && ...)
55 [[nodiscard]]
constexpr operator T()
const {
72 template <
typename... Es>
73 requires(std::is_same_v<Es, E> && ...)
83 template <
typename... Es>
84 requires(std::is_same_v<Es, E> && ...)
95 template <
typename... Es>
96 requires(std::is_same_v<Es, E> && ...)
106 template <
typename... Es>
107 requires(std::is_same_v<Es, E> && ...)
118 template <
typename... Es>
119 requires(std::is_same_v<Es, E> && ...)
120 [[nodiscard]]
constexpr bool onBit(Es... es)
const {
129 template <
typename... Es>
130 requires(std::is_same_v<Es, E> && ...)
131 [[nodiscard]]
constexpr bool onAnyBit(Es... es)
const {
132 return (
onBit_(es) || ...);
140 template <
typename... Es>
141 requires(std::is_same_v<Es, E> && ...)
142 [[nodiscard]]
constexpr bool onAllBit(Es... es)
const {
143 return (
onBit_(es) && ...);
151 template <
typename... Es>
152 requires(std::is_same_v<Es, E> && ...)
153 [[nodiscard]]
constexpr bool offBit(Es... es)
const {
162 template <
typename... Es>
163 requires(std::is_same_v<Es, E> && ...)
164 [[nodiscard]]
constexpr bool offAllBit(Es... es)
const {
173 template <
typename... Es>
174 requires(std::is_same_v<Es, E> && ...)
175 [[nodiscard]]
constexpr bool offAnyBit(Es... es)
const {
184 template <
typename... Es>
185 requires(std::is_same_v<Es, E> && ...)
186 [[nodiscard]]
constexpr T
maskBit(Es... es)
const {
194 template <
typename... Es>
195 requires(std::is_same_v<Es, E> && ...)
196 [[nodiscard]]
constexpr T
makeMask(Es... es)
const {
227 [[nodiscard]]
constexpr bool on(T mask)
const {
228 return (
bits & mask) != 0;
234 [[nodiscard]]
constexpr bool onAll(T mask)
const {
241 [[nodiscard]]
constexpr bool off(T mask)
const {
242 return (
bits & mask) == 0;
263 typedef std::underlying_type_t<E>
EI;
303 [[nodiscard]]
constexpr bool onBit_(E e)
const {
312 [[nodiscard]]
constexpr bool offBit_(E e)
const {
323 return static_cast<T
>(1) <<
static_cast<T
>(e);
332template <
size_t N,
typename E>
333 requires(std::is_enum_v<E> && N > 64)
345 std::fill(
bits.begin(),
bits.end(), 0);
354 template <
typename... Es>
355 requires(std::is_same_v<Es, E> && ...)
365 template <
typename... Es>
366 requires(std::is_same_v<Es, E> && ...)
377 template <
typename... Es>
378 requires(std::is_same_v<Es, E> && ...)
389 template <
typename... Es>
390 requires(std::is_same_v<Es, E> && ...)
391 [[nodiscard]]
constexpr bool onBit(Es... es)
const {
400 template <
typename... Es>
401 requires(std::is_same_v<Es, E> && ...)
402 [[nodiscard]]
constexpr bool onAnyBit(Es... es)
const {
403 return (
onBit_(es) || ...);
411 template <
typename... Es>
412 requires(std::is_same_v<Es, E> && ...)
413 [[nodiscard]]
constexpr bool onAllBit(Es... es)
const {
414 return (
onBit_(es) && ...);
422 template <
typename... Es>
423 requires(std::is_same_v<Es, E> && ...)
424 [[nodiscard]]
constexpr bool offBit(Es... es)
const {
433 template <
typename... Es>
434 requires(std::is_same_v<Es, E> && ...)
435 [[nodiscard]]
constexpr bool offAllBit(Es... es)
const {
444 template <
typename... Es>
445 requires(std::is_same_v<Es, E> && ...)
446 [[nodiscard]]
constexpr bool offAnyBit(Es... es)
const {
451 typedef std::underlying_type_t<E>
EI;
481 [[nodiscard]]
constexpr bool onBit_(E e)
const {
483 return (field & mask) != 0;
490 [[nodiscard]]
constexpr bool offBit_(E e)
const {
492 return (field & mask) == 0;
501 [[nodiscard]]
constexpr std::pair<T, T>
makeMask_(E e)
const {
502 EI ei =
static_cast<EI>(e);
504 return std::pair<T, T>(
bits[ei /
C],
static_cast<T>(1) << (ei %
C));
511 [[nodiscard]]
constexpr std::pair<T &, T>
makeMask_(E e) {
512 EI ei =
static_cast<EI>(e);
514 return std::pair<T &, T>(
bits[ei /
C],
static_cast<T>(1) << (ei %
C));
517 static constexpr size_t C = 8 *
sizeof(
T);
constexpr TBitFlagExt< N, eStatus > & changeBit(bool on, Es... es)
constexpr bool offBit(Es... es) const
Checks if all of the corresponding bits for the provided enum values are off.
constexpr bool onBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are on.
constexpr bool offAllBit(Es... es) const
constexpr bool onAllBit(Es... es) const
Checks if all of the corresponding bits for the provided enum values are on.
static constexpr size_t C
constexpr std::pair< T, T > makeMask_(eStatus e) const
std::array< T,(N+C - 1)/C > bits
constexpr TBitFlagExt< N, eStatus > & makeAllZero()
constexpr bool onBit_(eStatus e) const
constexpr std::pair< T &, T > makeMask_(E e)
Gets bit index and mask for a specific bit.
constexpr bool offBit_(eStatus e) const
constexpr void resetBit_(eStatus e)
constexpr TBitFlagExt< N, E > & resetBit(Es... es)
Resets the corresponding bits for the provided enum values.
constexpr void setBit_(eStatus e)
constexpr TBitFlagExt< N, eStatus > & setBit(Es... es)
constexpr TBitFlagExt()
Default constructor, initializes all flags to off.
constexpr bool offAnyBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are off.
constexpr bool onAnyBit(Es... es) const
constexpr void changeBit_(bool on, eStatus e)
std::underlying_type_t< E > EI
constexpr bool offBit(Es... es) const
Checks if all of the corresponding bits for the provided enum values are off.
constexpr bool onBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are on.
constexpr void toggleBit_(eAttribute e)
constexpr bool onAll(T mask) const
Checks if all bits are on in the specified mask.
constexpr bool offAllBit(Es... es) const
constexpr TBitFlag< u16, eAttribute > & setBit(Es... es)
constexpr TBitFlag()
Default constructor, initializes all flags to off.
constexpr bool onAllBit(Es... es) const
Checks if all of the corresponding bits for the provided enum values are on.
constexpr TBitFlag< T, E > & change(bool on, T mask)
Changes the bits using a direct mask.
constexpr T getDirect() const
Gets the current bit mask.
constexpr TBitFlag< u16, eAttribute > & changeBit(bool on, Es... es)
constexpr u16 makeMask_(eAttribute e) const
constexpr TBitFlag(E e)
Constructor that initializes the bit flags with a given enum.
constexpr void makeAllZero()
constexpr bool onBit_(eAttribute e) const
constexpr TBitFlag(T mask)
Constructor that initializes the bit flags with a given mask.
constexpr TBitFlag< T, E > & reset(T mask)
Resets the bits using a direct mask.
constexpr TBitFlag< T, E > & operator=(const TBitFlag< T, E > &rhs)
Assignment operator.
constexpr bool offBit_(eAttribute e) const
constexpr void resetBit_(eAttribute e)
constexpr u16 makeMask(Es... es) const
constexpr TBitFlag< T, E > & toggleBit(Es... es)
Toggles the corresponding bits for the provided enum values.
constexpr bool on(u16 mask) const
constexpr void setDirect(u16 mask)
constexpr TBitFlag< T, E > & set(T mask)
Sets the bits using a direct mask.
constexpr void setBit_(eAttribute e)
constexpr bool off(T mask) const
Checks if all bits are off in the specified mask.
constexpr T maskBit(Es... es) const
Creates an applied mask of the corresponding bits for the provided enum values.
constexpr TBitFlag< T, E > & resetBit(Es... es)
Resets the corresponding bits for the provided enum values.
constexpr bool offAnyBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are off.
constexpr bool onAnyBit(Es... es) const
constexpr void changeBit_(bool on, eAttribute e)
std::underlying_type_t< eAttribute > EI
static constexpr size_t MAX_CAPACITY