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 | |
typedef VALUE_TYPE | value_type |
The underlying integral value type that holds the bits representing the flags. | |
typedef ENUM_TYPE | enum_type |
Type of the enum that is the source of the flags. | |
typedef enum_flags< ENUM_TYPE, VALUE_TYPE > | self_type |
using | value_type = VALUE_TYPE |
The underlying integral value type that holds the bits representing the flags. | |
using | enum_type = ENUM |
Type of the enum that is the source of the flags. | |
using | self_type = enum_flags |
using | flag_changes = enum_flag_changes< ENUM, VALUE_TYPE > |
Public Member Functions | |
EF_CONSTEXPR | enum_flags (const enum_flags &other) EF_NOEXCEPT |
EF_CONSTEXPR enum_flags & | operator= (const enum_flags &other) EF_NOEXCEPT |
EF_CONSTEXPR | enum_flags (enum_type base_value) EF_NOEXCEPT |
EF_CONSTEXPR | enum_flags (value_type value) EF_NOEXCEPT |
EF_NODISCARD EF_CONSTEXPR bool | is_set (enum_type flag) const EF_NOEXCEPT |
Returns whether or not flag is set. | |
EF_NODISCARD EF_CONSTEXPR bool | contain (enum_type flag) const EF_NOEXCEPT |
Same as is_set. | |
EF_NODISCARD EF_CONSTEXPR bool | contains (enum_type flag) const EF_NOEXCEPT |
Same as is_set. | |
EF_NODISCARD EF_CONSTEXPR bool | are_any_set () const EF_NOEXCEPT |
Returns whether or not any of the given flags are set. | |
EF_NODISCARD EF_CONSTEXPR bool | are_any_set (self_type other) const EF_NOEXCEPT |
Returns whether or not any of the flags in the other set are set. | |
EF_NODISCARD EF_CONSTEXPR bool | are_all_set (self_type other) const EF_NOEXCEPT |
Returns whether or not all of the flags in the other set are set. | |
EF_CONSTEXPR EF_EXPLICITOP | operator bool () const EF_NOEXCEPT |
EF_NODISCARD EF_CONSTEXPR enum_type | to_enum_type () const EF_NOEXCEPT |
Returns the underlying value representing this set cast to the enum_type. | |
EF_CONSTEXPR self_type & | set (enum_type e) EF_NOEXCEPT |
Sets the given flag. | |
EF_CONSTEXPR self_type & | set (self_type other) EF_NOEXCEPT |
Sets the flags in the other | |
EF_CONSTEXPR self_type & | unset (enum_type e) EF_NOEXCEPT |
Unsets the given flag. | |
EF_CONSTEXPR self_type & | unset (self_type other) EF_NOEXCEPT |
Unsets the flags in the other set. | |
EF_CONSTEXPR self_type & | toggle (enum_type e) EF_NOEXCEPT |
Toggles the given flag. | |
EF_CONSTEXPR self_type & | toggle (self_type other) EF_NOEXCEPT |
Toggles the flags in the other set. | |
EF_CONSTEXPR self_type & | set_to (enum_type e, bool val) EF_NOEXCEPT |
Sets the given flags to val | |
EF_CONSTEXPR self_type & | set_to (self_type other, bool val) EF_NOEXCEPT |
Sets the flags in the other set to val | |
EF_NODISCARD EF_CONSTEXPR self_type | but_only (self_type flags) const EF_NOEXCEPT |
Returns a value with our bits from only the flags that are also set in flags (an intersection) | |
EF_NODISCARD EF_CONSTEXPR self_type | intersected_with (self_type flags) const EF_NOEXCEPT |
Returns a value with our bits from only the flags that are also set in flags (an intersection) | |
EF_NODISCARD EF_CONSTEXPR self_type | operator+ (enum_type flag) const EF_NOEXCEPT |
EF_NODISCARD EF_CONSTEXPR self_type | operator- (enum_type flag) const EF_NOEXCEPT |
EF_NODISCARD EF_CONSTEXPR self_type | operator+ (self_type flags) const EF_NOEXCEPT |
EF_NODISCARD EF_CONSTEXPR self_type | operator- (self_type flags) const EF_NOEXCEPT |
EF_CONSTEXPR bool | operator== (self_type other) const EF_NOEXCEPT |
EF_CONSTEXPR bool | operator< (enum_flags const &other) const EF_NOEXCEPT |
EF_CONSTEXPR bool | operator> (enum_flags const &other) const EF_NOEXCEPT |
EF_CONSTEXPR bool | empty () const EF_NOEXCEPT |
EF_CONSTEXPR void | clear () EF_NOEXCEPT |
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 |
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 (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. | |
constexpr int | count () const noexcept |
Returns the number of flags set. | |
constexpr ENUM | nth_set (size_t n) const noexcept |
Returns the value of the n th set bit in the set. | |
constexpr ENUM | first_set () const noexcept |
Returns the lowest numerical value in the set. Returns an unspecified value if no values are in the set. | |
template<typename T , typename... ARGS> | |
constexpr bool | contains_any_of (T 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 >... 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 >... ARGS> | |
constexpr self_type & | unset (ARGS... args) noexcept |
TODO: insert() as an alias for set() | |
constexpr self_type & | unset (self_type other) noexcept |
Unsets the flags in the other set. | |
template<std::convertible_to< ENUM >... ARGS> | |
constexpr self_type & | toggle (ARGS... args) noexcept |
TODO: erase() as an alias for unset() | |
constexpr self_type & | toggle (self_type other) noexcept |
Toggles the flags in the other set. | |
template<std::convertible_to< ENUM >... 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 | except_for (self_type flags) const noexcept |
constexpr self_type | without (self_type flags) const noexcept |
template<std::convertible_to< ENUM >... ARGS> | |
constexpr self_type | except_for (ARGS... args) const noexcept |
template<std::convertible_to< ENUM >... ARGS> | |
constexpr self_type | without (ARGS... args) const noexcept |
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 | |
EF_NODISCARD static EF_CONSTEXPR self_type | from_bits (value_type val) EF_NOEXCEPT |
Creates the enum_flags set from the given underlying bits. | |
EF_NODISCARD static EF_CONSTEXPR self_type | all () EF_NOEXCEPT |
Returns a value with all bits set (including the ones not in the enum, if any) | |
EF_NODISCARD static EF_CONSTEXPR self_type | all (enum_type last) EF_NOEXCEPT |
Returns a value with all bits set, up to and including the last | |
EF_NODISCARD static EF_CONSTEXPR self_type | none () EF_NOEXCEPT |
Returns a value with none of the bits set. | |
static constexpr self_type | from_bits (value_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 | 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)
uint64_t
by default)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 28 of file enum_flags.h.
typedef ENUM_TYPE ghassanpl::enum_flags< ENUM_TYPE, VALUE_TYPE >::enum_type |
Type of the enum that is the source of the flags.
Definition at line 34 of file enum_flags.h.
using ghassanpl::enum_flags< ENUM_TYPE, VALUE_TYPE >::enum_type = ENUM |
Type of the enum that is the source of the flags.
Definition at line 56 of file enum_flags.h.
using ghassanpl::enum_flags< ENUM_TYPE, VALUE_TYPE >::flag_changes = enum_flag_changes<ENUM, VALUE_TYPE> |
Definition at line 306 of file enum_flags.h.
typedef enum_flags<ENUM_TYPE, VALUE_TYPE> ghassanpl::enum_flags< ENUM_TYPE, VALUE_TYPE >::self_type |
Definition at line 35 of file enum_flags.h.
using ghassanpl::enum_flags< ENUM_TYPE, VALUE_TYPE >::self_type = enum_flags |
Definition at line 57 of file enum_flags.h.
typedef VALUE_TYPE ghassanpl::enum_flags< ENUM_TYPE, VALUE_TYPE >::value_type |
The underlying integral value type that holds the bits representing the flags.
Definition at line 31 of file enum_flags.h.
using ghassanpl::enum_flags< ENUM_TYPE, VALUE_TYPE >::value_type = VALUE_TYPE |
The underlying integral value type that holds the bits representing the flags.
Definition at line 53 of file enum_flags.h.
|
inline |
Definition at line 39 of file enum_flags.h.
|
inline |
Definition at line 40 of file enum_flags.h.
|
inline |
Definition at line 43 of file enum_flags.h.
|
inlineexplicit |
Definition at line 44 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 67 of file enum_flags.h.
|
inlineexplicitconstexprnoexcept |
Definition at line 68 of file enum_flags.h.
|
inlineconstexprnoexcept |
Constructs the value with all the given flags set.
Definition at line 72 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 86 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 96 of file enum_flags.h.
|
inlinestatic |
Returns a value with all bits set (including the ones not in the enum, if any)
Definition at line 54 of file enum_flags.h.
|
inlinestaticconstexprnoexcept |
Returns a value with all bits set (including the ones not in the enum, if any)
Definition at line 84 of file enum_flags.h.
|
inlinestatic |
Returns a value with all bits set, up to and including the last
Definition at line 57 of file enum_flags.h.
|
inlinestaticconstexprnoexcept |
Returns a value with all bits set, up to and including the last
Definition at line 90 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 308 of file enum_flags.h.
|
inline |
Returns whether or not all of the flags in the other
set are set.
Definition at line 78 of file enum_flags.h.
|
inline |
Returns whether or not any of the given flags are set.
Definition at line 71 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns whether or not any of the given flags are set.
Definition at line 135 of file enum_flags.h.
|
inline |
Returns whether or not any of the flags in the other
set are set.
Definition at line 75 of file enum_flags.h.
|
inlinenoexcept |
Definition at line 269 of file enum_flags.h.
|
inline |
Returns a value with our bits from only the flags that are also set in flags
(an intersection)
Definition at line 115 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns a value with our bits from only the flags that are also set in flags
(an intersection)
Definition at line 203 of file enum_flags.h.
|
inlinenoexcept |
Definition at line 271 of file enum_flags.h.
|
inlinenoexcept |
Definition at line 272 of file enum_flags.h.
|
inline |
Definition at line 141 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 275 of file enum_flags.h.
|
inline |
Same as is_set.
Definition at line 66 of file enum_flags.h.
|
inlineconstexprnoexcept |
Same as is_set.
Definition at line 104 of file enum_flags.h.
|
inline |
Same as is_set.
Definition at line 68 of file enum_flags.h.
|
inlineconstexprnoexcept |
Same as is_set.
Definition at line 107 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns whether or not all of the given flags are set.
Definition at line 149 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns whether or not all of the flags in the other
set are set.
Definition at line 156 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns whether or not any of the flags in the other
set are set.
Definition at line 144 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns whether or not any of the given flags are set.
Definition at line 128 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns the number of flags set.
Definition at line 111 of file enum_flags.h.
|
inline |
Definition at line 140 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 274 of file enum_flags.h.
|
inlinenoexcept |
Definition at line 270 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 224 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 219 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns the lowest numerical value in the set. Returns an unspecified value if no values are in the set.
Definition at line 123 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 |
callback
if it returned something true, or the value-initialized return typeTODO: See if this would be faster with a simple loop
Definition at line 284 of file enum_flags.h.
|
inlinestatic |
Creates the enum_flags set from the given underlying bits.
Definition at line 47 of file enum_flags.h.
|
inlinestaticconstexprnoexcept |
Creates the enum_flags set from the given underlying bits.
Definition at line 76 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns whether *this == all()
Definition at line 139 of file enum_flags.h.
|
inline |
Returns a value with our bits from only the flags that are also set in flags
(an intersection)
Definition at line 118 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns a value with our bits from only the flags that are also set in flags
(an intersection)
Definition at line 207 of file enum_flags.h.
|
inline |
Returns whether or not flag
is set.
Definition at line 63 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns whether or not flag
is set.
Definition at line 100 of file enum_flags.h.
|
inlinestatic |
Returns a value with none of the bits set.
Definition at line 60 of file enum_flags.h.
|
inlinestaticconstexprnoexcept |
Returns a value with none of the bits set.
Definition at line 94 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns the value of the n
th set bit in the set.
Definition at line 115 of file enum_flags.h.
|
inline |
Definition at line 80 of file enum_flags.h.
|
inlineexplicitconstexprnoexcept |
Definition at line 158 of file enum_flags.h.
|
inline |
Definition at line 120 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 210 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 322 of file enum_flags.h.
|
inline |
Definition at line 123 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 215 of file enum_flags.h.
|
inline |
Definition at line 121 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 212 of file enum_flags.h.
|
inline |
Definition at line 124 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 217 of file enum_flags.h.
|
inline |
Definition at line 135 of file enum_flags.h.
|
inline |
Definition at line 41 of file enum_flags.h.
|
inline |
Definition at line 132 of file enum_flags.h.
|
inline |
Definition at line 136 of file enum_flags.h.
|
inlineconstexprnoexcept |
Sets the given flags.
Definition at line 166 of file enum_flags.h.
|
inline |
Sets the given flag.
Definition at line 86 of file enum_flags.h.
|
inline |
Sets the flags in the other
Definition at line 88 of file enum_flags.h.
|
inlineconstexprnoexcept |
Sets the flags in the other
Definition at line 168 of file enum_flags.h.
|
inlineconstexprnoexcept |
Sets the given flags to val
Definition at line 188 of file enum_flags.h.
|
inlineconstexprnoexcept |
Sets the flags in the other
set to val
Definition at line 195 of file enum_flags.h.
|
inline |
Sets the given flags to val
Definition at line 101 of file enum_flags.h.
|
inline |
Sets the flags in the other
set to val
Definition at line 108 of file enum_flags.h.
|
inline |
Returns the underlying value representing this set cast to the enum_type.
Definition at line 83 of file enum_flags.h.
|
inlineconstexprnoexcept |
Returns the underlying value representing this set cast to the enum_type.
Definition at line 162 of file enum_flags.h.
|
inlineconstexprnoexcept |
TODO: erase()
as an alias for unset()
Toggles the given flags
Definition at line 182 of file enum_flags.h.
|
inline |
Toggles the given flag.
Definition at line 96 of file enum_flags.h.
|
inline |
Toggles the flags in the other
set.
Definition at line 98 of file enum_flags.h.
|
inlineconstexprnoexcept |
Toggles the flags in the other
set.
Definition at line 184 of file enum_flags.h.
|
inlineconstexprnoexcept |
TODO: insert()
as an alias for set()
Unsets the given flags
Definition at line 174 of file enum_flags.h.
|
inline |
Unsets the given flag.
Definition at line 91 of file enum_flags.h.
|
inline |
Unsets the flags in the other
set.
Definition at line 93 of file enum_flags.h.
|
inlineconstexprnoexcept |
Unsets the flags in the other
set.
Definition at line 176 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 226 of file enum_flags.h.
|
inlineconstexprnoexcept |
Definition at line 221 of file enum_flags.h.
value_type ghassanpl::enum_flags< ENUM_TYPE, VALUE_TYPE >::bits |
Definition at line 37 of file enum_flags.h.