|
header_utils
|
A (constexpr) value struct that represents a set of bits mapped to an enum (implemented as a bitset). More...
#include <enum_flags.h>
Public Types | |
| using | value_type |
| The underlying integral value type that holds the bits representing the flags. | |
| using | enum_type |
| Type of the enum that is the source of the flags. | |
| using | self_type |
| using | flag_changes |
Public Member Functions | |
| constexpr | enum_flags (const enum_flags &) noexcept=default |
| constexpr | enum_flags (enum_flags &&) noexcept=default |
| constexpr enum_flags & | operator= (const enum_flags &) noexcept=default |
| constexpr enum_flags & | operator= (enum_flags &&) noexcept=default |
| constexpr | enum_flags (enum_type base_value) noexcept |
| template<typename U = VALUE_TYPE> | |
| constexpr | enum_flags (value_type value) noexcept |
| template<typename... ARGS> | |
| constexpr | enum_flags (enum_type base_value, ARGS... args) noexcept |
| Constructs the value with all the given flags set. | |
| constexpr | enum_flags (std::initializer_list< enum_type > values) noexcept |
| constexpr | enum_flags (all_flags_t) noexcept |
| constexpr | enum_flags (no_flags_t) noexcept |
| constexpr bool | is_set (enum_type flag) const noexcept |
| Returns whether or not flag is set. | |
| constexpr bool | contain (enum_type flag) const noexcept |
| Same as is_set. | |
| constexpr bool | contains (enum_type flag) const noexcept |
| Same as is_set. | |
| template<std::convertible_to< enum_type >... FLAGS> | |
| constexpr auto | get (enum_type flag1, enum_type flag2, FLAGS... rest) |
| Returns an array of bools that are set to the value of contains(param) for each flag parameter Useful for destructuring. | |
| constexpr int | count () const noexcept |
| Returns the number of flags set. | |
| constexpr enum_type | nth_set (size_t n) const noexcept |
| Returns the value of the nth set bit in the set Preconditions: n must be less than the number of bits set (n < count()). | |
| constexpr enum_type | first_set () const noexcept |
| Returns the lowest numerical value in the set. Returns an unspecified value if no values are in the set. | |
| constexpr enum_type | last_set () const noexcept |
| Returns the highest numerical value in the set, or enum_type(-1) if no values are in the set. | |
| template<typename... ARGS> | |
| constexpr bool | contains_any_of (enum_type arg, ARGS... args) const noexcept |
| Returns whether or not any of the given flags are set. | |
| template<typename... ARGS> | |
| constexpr bool | contains_none_of (enum_type arg, ARGS... args) const noexcept |
| Returns whether or not any of the given flags are set. | |
| constexpr bool | are_any_set () const noexcept |
| Returns whether or not any of the given flags are set. | |
| constexpr bool | full () const noexcept |
| Returns whether *this == all(). | |
| constexpr bool | contains_any_of (self_type other) const noexcept |
| Returns whether or not any of the flags in the other set are set. | |
| template<typename... ARGS> | |
| constexpr bool | contains_all_of (ARGS... args) const noexcept |
| Returns whether or not all of the given flags are set. | |
| constexpr bool | contains_all_of (self_type other) const noexcept |
| Returns whether or not all of the flags in the other set are set. | |
| constexpr | operator bool () const noexcept |
| constexpr enum_type | to_enum_type () const noexcept |
| Returns the underlying value representing this set cast to the enum_type. | |
| template<std::convertible_to< enum_type >... ARGS> | |
| constexpr self_type & | set (ARGS... args) noexcept |
| Sets the given flags. | |
| constexpr self_type & | set (self_type other) noexcept |
| Sets the flags in the other. | |
| template<std::convertible_to< enum_type >... ARGS> | |
| constexpr self_type & | unset (ARGS... args) noexcept |
| Unsets the given flags. | |
| constexpr self_type & | unset (self_type other) noexcept |
| Unsets the flags in the other set. | |
| template<std::convertible_to< enum_type >... ARGS> | |
| constexpr self_type & | toggle (ARGS... args) noexcept |
| Toggles the given flags. | |
| constexpr self_type & | toggle (self_type other) noexcept |
| Toggles the flags in the other set. | |
| template<std::convertible_to< enum_type >... ARGS> | |
| constexpr self_type & | set_to (bool val, ARGS... args) noexcept |
| Sets the given flags to val. | |
| constexpr self_type & | set_to (bool val, self_type other) noexcept |
| Sets the flags in the other set to val. | |
| constexpr self_type | but_only (self_type flags) const noexcept |
| Returns a value with our bits from only the flags that are also set in flags (an intersection). | |
| constexpr self_type | intersected_with (self_type flags) const noexcept |
| Returns a value with our bits from only the flags that are also set in flags (an intersection). | |
| constexpr self_type | operator+ (enum_type flag) const noexcept |
| constexpr self_type | operator- (enum_type flag) const noexcept |
| constexpr self_type | operator+ (self_type flags) const noexcept |
| constexpr self_type | operator- (self_type flags) const noexcept |
| constexpr self_type | operator- () const noexcept |
| constexpr self_type | except_for (self_type flags) const noexcept |
| constexpr self_type | without (self_type flags) const noexcept |
| template<std::convertible_to< enum_type >... ARGS> | |
| constexpr self_type | except_for (ARGS... args) const noexcept |
| template<std::convertible_to< enum_type >... ARGS> | |
| constexpr self_type | without (ARGS... args) const noexcept |
| constexpr self_type & | operator+= (enum_type flag) noexcept |
| constexpr self_type & | operator-= (enum_type flag) noexcept |
| constexpr self_type & | operator+= (self_type flags) noexcept |
| constexpr self_type & | operator-= (self_type flags) noexcept |
| constexpr auto | operator<=> (enum_flags const &other) const noexcept=default |
| iterator | begin () const noexcept |
| iterator | end () const noexcept |
| iterator | cbegin () const noexcept |
| iterator | cend () const noexcept |
| constexpr bool | empty () const noexcept |
| constexpr void | clear () noexcept |
| template<typename FUNC> | |
| constexpr auto | for_each (FUNC &&callback) const |
| Calls callback for each enum flag in the set. | |
| constexpr void | apply (flag_changes changes) noexcept |
| constexpr self_type | operator+ (flag_changes changes) const noexcept |
Static Public Member Functions | |
| template<integral_or_enum BITS_TYPE> | |
| static constexpr self_type | from_bits (BITS_TYPE val) noexcept |
| Creates the enum_flags set from the given underlying bits. | |
| static constexpr self_type | all () noexcept |
| Returns a value with all bits set (including the ones not in the enum, if any). | |
| static constexpr self_type | all (enum_type last) noexcept |
| Returns a value with all bits set, up to and including the last. | |
| static constexpr self_type | all_between (enum_type first, enum_type last) noexcept |
| Returns a value with bits starting with first, up to and including last, set. | |
| static constexpr self_type | none () noexcept |
| Returns a value with none of the bits set. | |
Public Attributes | |
| value_type | bits |
A (constexpr) value struct that represents a set of bits mapped to an enum (implemented as a bitset).
| ENUM | the type containing the value flags the set will hold |
| VALUE_TYPE | the underlying integral value that stores the bits representing the flags |
Definition at line 59 of file enum_flags.h.
| using ghassanpl::enum_flags< ENUM, VALUE_TYPE >::enum_type |
Type of the enum that is the source of the flags.
Definition at line 65 of file enum_flags.h.
| using ghassanpl::enum_flags< ENUM, VALUE_TYPE >::flag_changes |
Definition at line 348 of file enum_flags.h.
| using ghassanpl::enum_flags< ENUM, VALUE_TYPE >::self_type |
Definition at line 66 of file enum_flags.h.
| using ghassanpl::enum_flags< ENUM, VALUE_TYPE >::value_type |
The underlying integral value type that holds the bits representing the flags.
Definition at line 62 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 76 of file enum_flags.h.
|
inlineexplicitconstexprnoexcept |
Definition at line 79 of file enum_flags.h.
|
inlineconstexprnoexcept |
Constructs the value with all the given flags set.
Definition at line 86 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 88 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 105 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 119 of file enum_flags.h.
|
inlinestaticnodiscardconstexprnoexcept |
Returns a value with all bits set (including the ones not in the enum, if any).
Definition at line 103 of file enum_flags.h.
|
inlinestaticnodiscardconstexprnoexcept |
Returns a value with all bits set, up to and including the last.
Definition at line 109 of file enum_flags.h.
|
inlinestaticnodiscardconstexprnoexcept |
Returns a value with bits starting with first, up to and including last, set.
Definition at line 113 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 350 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns whether or not any of the given flags are set.
Definition at line 179 of file enum_flags.h.
|
inlinenoexcept |
Definition at line 311 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns a value with our bits from only the flags that are also set in flags (an intersection).
Definition at line 243 of file enum_flags.h.
|
inlinenoexcept |
Definition at line 313 of file enum_flags.h.
|
inlinenoexcept |
Definition at line 314 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 317 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Same as is_set.
Definition at line 127 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Same as is_set.
Definition at line 130 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns whether or not all of the given flags are set.
Definition at line 193 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns whether or not all of the flags in the other set are set.
Definition at line 200 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns whether or not any of the given flags are set.
Definition at line 164 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns whether or not any of the flags in the other set are set.
Definition at line 188 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns whether or not any of the given flags are set.
Definition at line 172 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns the number of flags set.
Definition at line 142 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 316 of file enum_flags.h.
|
inlinenoexcept |
Definition at line 312 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 266 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 261 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns the lowest numerical value in the set. Returns an unspecified value if no values are in the set.
Definition at line 155 of file enum_flags.h.
|
inlineconstexpr |
Calls callback for each enum flag in the set.
| callback | The function to call. It can return something convertible bool, and if it does, the iteration will stop when the function returns something true |
TODO: See if this would be faster with a simple loop
Definition at line 326 of file enum_flags.h.
|
inlinestaticnodiscardconstexprnoexcept |
Creates the enum_flags set from the given underlying bits.
Definition at line 95 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns whether *this == all().
Definition at line 183 of file enum_flags.h.
|
inlineconstexpr |
Returns an array of bools that are set to the value of contains(param) for each flag parameter Useful for destructuring.
Definition at line 135 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns a value with our bits from only the flags that are also set in flags (an intersection).
Definition at line 247 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns whether or not flag is set.
Definition at line 123 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns the highest numerical value in the set, or enum_type(-1) if no values are in the set.
Definition at line 159 of file enum_flags.h.
|
inlinestaticnodiscardconstexprnoexcept |
Returns a value with none of the bits set.
Definition at line 117 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns the value of the nth set bit in the set Preconditions: n must be less than the number of bits set (n < count()).
Definition at line 147 of file enum_flags.h.
|
inlineexplicitconstexprnoexcept |
Definition at line 202 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 250 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 364 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 255 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 270 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 273 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 259 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 252 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 257 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 271 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 274 of file enum_flags.h.
|
inlineconstexprnoexcept |
Sets the given flags.
Definition at line 210 of file enum_flags.h.
|
inlineconstexprnoexcept |
Sets the flags in the other.
Definition at line 212 of file enum_flags.h.
|
inlineconstexprnoexcept |
Sets the given flags to val.
Definition at line 228 of file enum_flags.h.
|
inlineconstexprnoexcept |
Sets the flags in the other set to val.
Definition at line 235 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Returns the underlying value representing this set cast to the enum_type.
Definition at line 206 of file enum_flags.h.
|
inlineconstexprnoexcept |
Toggles the given flags.
Definition at line 222 of file enum_flags.h.
|
inlineconstexprnoexcept |
Toggles the flags in the other set.
Definition at line 224 of file enum_flags.h.
|
inlineconstexprnoexcept |
Unsets the given flags.
Definition at line 216 of file enum_flags.h.
|
inlineconstexprnoexcept |
Unsets the flags in the other set.
Definition at line 218 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 268 of file enum_flags.h.
|
inlinenodiscardconstexprnoexcept |
Definition at line 263 of file enum_flags.h.
| value_type ghassanpl::enum_flags< ENUM, VALUE_TYPE >::bits |
Definition at line 68 of file enum_flags.h.