#include <BitFlag.hh>
Wrapper around an integral type with an enum corresponding to its bits.
| T | The underlying integral type. |
| E | The enum to correspond to. |
Definition at line 16 of file BitFlag.hh.
Public Member Functions | |
| constexpr | TBitFlag () |
| Default constructor, initializes all flags to off. | |
| constexpr | TBitFlag (T mask) |
| Constructor that initializes the bit flags with a given mask. | |
| constexpr | TBitFlag (E e) |
| Constructor that initializes the bit flags with a given enum. | |
| constexpr | operator T () const |
| Conversion operator to the underlying integral type. | |
| constexpr TBitFlag< T, E > & | operator= (const TBitFlag< T, E > &rhs) |
| Assignment operator. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr TBitFlag< T, E > & | setBit (Es... es) |
| Sets the corresponding bits for the provided enum values. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr TBitFlag< T, E > & | resetBit (Es... es) |
| Resets the corresponding bits for the provided enum values. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr TBitFlag< T, E > & | changeBit (bool on, Es... es) |
| Changes the state of the corresponding bits for the provided enum values. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr TBitFlag< T, E > & | toggleBit (Es... es) |
| Toggles the corresponding bits for the provided enum values. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr bool | onBit (Es... es) const |
| Checks if any of the corresponding bits for the provided enum values are on. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr bool | onAnyBit (Es... es) const |
| Checks if any of the corresponding bits for the provided enum values are on. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr bool | onAllBit (Es... es) const |
| Checks if all of the corresponding bits for the provided enum values are on. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr bool | offBit (Es... es) const |
| Checks if all of the corresponding bits for the provided enum values are off. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr bool | offAllBit (Es... es) const |
| Checks if all of the corresponding bits for the provided enum values are off. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr bool | offAnyBit (Es... es) const |
| Checks if any of the corresponding bits for the provided enum values are off. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr T | maskBit (Es... es) const |
| Creates an applied mask of the corresponding bits for the provided enum values. | |
| template<typename... Es> requires (std::is_same_v<Es, E> && ...) | |
| constexpr T | makeMask (Es... es) const |
| Creates a mask of the corresponding bits for the provided enum values. | |
| constexpr TBitFlag< T, E > & | set (T mask) |
| Sets the bits using a direct mask. | |
| constexpr TBitFlag< T, E > & | reset (T mask) |
| Resets the bits using a direct mask. | |
| constexpr TBitFlag< T, E > & | change (bool on, T mask) |
| Changes the bits using a direct mask. | |
| constexpr bool | on (T mask) const |
| Checks if any bits are on in the specified mask. | |
| constexpr bool | onAll (T mask) const |
| Checks if all bits are on in the specified mask. | |
| constexpr bool | off (T mask) const |
| Checks if all bits are off in the specified mask. | |
| constexpr void | makeAllZero () |
| Resets all the bits to zero. | |
| constexpr T | getDirect () const |
| Gets the current bit mask. | |
| constexpr void | setDirect (T mask) |
| Sets the bits using a direct mask. | |
Private Types | |
| typedef std::underlying_type_t< E > | EI |
Private Member Functions | |
| constexpr void | setBit_ (E e) |
| Internal. Sets a specific bit. | |
| constexpr void | resetBit_ (E e) |
| Internal. Resets a specific bit. | |
| constexpr void | changeBit_ (bool on, E e) |
| Internal. Changes a specific bit. | |
| constexpr void | toggleBit_ (E e) |
| Internal. Toggles a specific bit. | |
| constexpr bool | onBit_ (E e) const |
| Checks if a specific bit is on. | |
| constexpr bool | offBit_ (E e) const |
| Checks if a specific bit is off. | |
| constexpr T | makeMask_ (E e) const |
| Creates a mask for a specific bit. | |
Private Attributes | |
| T | bits |
| The bit mask representing the flags. | |
Static Private Attributes | |
| static constexpr size_t | MAX_CAPACITY = std::numeric_limits<T>::digits |
|
private |
Definition at line 246 of file BitFlag.hh.
|
inlineconstexpr |
Default constructor, initializes all flags to off.
Matches the expression bits = 0.
Definition at line 19 of file BitFlag.hh.
|
inlineconstexpr |
Constructor that initializes the bit flags with a given mask.
Matches the expression bits = mask.
| mask | The initial bit mask. |
Definition at line 26 of file BitFlag.hh.
|
inlineconstexpr |
Constructor that initializes the bit flags with a given enum.
Matches the expression bits = eEnum::val.
| e | The initial enum. |
Definition at line 33 of file BitFlag.hh.
|
inlineconstexpr |
Changes the bits using a direct mask.
| on | Determines whether to set or reset the bits. |
| mask | The bit mask to change. |
Definition at line 203 of file BitFlag.hh.
|
inlineconstexpr |
Changes the state of the corresponding bits for the provided enum values.
| ...Es | Variadic template for packing. |
| on | Determines whether to set or reset the bits. |
| ...es | Enum values representing the bits to change. |
Definition at line 80 of file BitFlag.hh.
|
inlineconstexprprivate |
Internal. Changes a specific bit.
Validates that e is in the range of T.
| on | Determines whether to set or reset the bit. |
| e | Enum value respresenting the bit to change. |
Definition at line 269 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
|
inlineconstexpr |
Resets all the bits to zero.
Definition at line 229 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Creates a mask of the corresponding bits for the provided enum values.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to check. |
Definition at line 179 of file BitFlag.hh.
|
inlinenodiscardconstexprprivate |
Creates a mask for a specific bit.
Matches the expression (1 << e). Validates that e is in the range of T.
| e |
Definition at line 304 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Creates an applied mask of the corresponding bits for the provided enum values.
Matches the expression (bits & mask).
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to check. |
Definition at line 169 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if all bits are off in the specified mask.
| mask | The bit mask to check. |
Definition at line 224 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if all of the corresponding bits for the provided enum values are off.
Matches the expression (bits & mask) == 0.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to check. |
Definition at line 147 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if any of the corresponding bits for the provided enum values are off.
Matches the expression (bits & mask) != mask.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to check. |
Definition at line 158 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if all of the corresponding bits for the provided enum values are off.
Matches the expression (bits & mask) == 0.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to check. |
Definition at line 136 of file BitFlag.hh.
|
inlinenodiscardconstexprprivate |
Checks if a specific bit is off.
Validates that e is in the range of T.
| e | Enum value representing the bit to change. |
Definition at line 295 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if any bits are on in the specified mask.
| mask | The bit mask to check. |
Definition at line 210 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if all bits are on in the specified mask.
| mask | The bit mask to check. |
Definition at line 217 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if all of the corresponding bits for the provided enum values are on.
Matches the expression (bits & mask) == mask.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to check. |
Definition at line 125 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if any of the corresponding bits for the provided enum values are on.
Matches the expression (bits & mask) != 0.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to check. |
Definition at line 114 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Checks if any of the corresponding bits for the provided enum values are on.
Matches the expression (bits & mask) != 0.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to check. |
Definition at line 103 of file BitFlag.hh.
|
inlinenodiscardconstexprprivate |
Checks if a specific bit is on.
Validates that e is in the range of T.
| e | Enum value representing the bit to change. |
Definition at line 286 of file BitFlag.hh.
|
inlinenodiscardconstexpr |
Conversion operator to the underlying integral type.
Definition at line 38 of file BitFlag.hh.
|
inlineconstexpr |
Assignment operator.
| rhs | Source. |
Definition at line 45 of file BitFlag.hh.
|
inlineconstexpr |
Resets the bits using a direct mask.
| mask | The bit mask to reset. |
Definition at line 194 of file BitFlag.hh.
|
inlineconstexpr |
Resets the corresponding bits for the provided enum values.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to reset. |
Definition at line 68 of file BitFlag.hh.
|
inlineconstexprprivate |
Internal. Resets a specific bit.
Validates that e is in the range of T.
| e | Enum value representing the bit to reset. |
Definition at line 260 of file BitFlag.hh.
|
inlineconstexpr |
Sets the bits using a direct mask.
| mask | The bit mask to set. |
Definition at line 186 of file BitFlag.hh.
|
inlineconstexpr |
Sets the corresponding bits for the provided enum values.
Matches the expression bits |= mask.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to set. |
Definition at line 57 of file BitFlag.hh.
|
inlineconstexprprivate |
Internal. Sets a specific bit.
Validates that e is in the range of T.
| e | Enum value representing the bit to set. |
Definition at line 252 of file BitFlag.hh.
|
inlineconstexpr |
Sets the bits using a direct mask.
| mask | The bit mask to set. |
Definition at line 241 of file BitFlag.hh.
|
inlineconstexpr |
Toggles the corresponding bits for the provided enum values.
| ...Es | Variadic template for packing. |
| ...es | Enum values representing the bits to toggle. |
Definition at line 91 of file BitFlag.hh.
|
inlineconstexprprivate |
Internal. Toggles a specific bit.
Validates that e is in the range of T.
| e | Enum value representing the bit to change. |
Definition at line 277 of file BitFlag.hh.
|
private |
The bit mask representing the flags.
Definition at line 309 of file BitFlag.hh.
|
staticconstexprprivate |
Definition at line 247 of file BitFlag.hh.