Type identifying a set of bits. More...
#include <BitMask.h>
Public Types | |
using | Storage_t = Storage |
using | This_t = Bits_t< Storage > |
This type. More... | |
using | Flag_t = util::flags::Flag_t< Storage_t > |
Type of flag matching our storage. More... | |
Public Member Functions | |
constexpr | Bits_t ()=default |
Default constructor: no bit set. More... | |
constexpr | Bits_t (Flag_t flag) |
Constructs from a single flag. More... | |
constexpr | Bits_t (Storage_t bits) |
Constructs from a set of bits. More... | |
constexpr | operator bool () const |
Returns true if there is at least one bit set. More... | |
constexpr bool | operator! () const |
Returns true if there is no bit set. More... | |
Bit query operations | |
constexpr bool | empty () const |
Returns whether there is no bit set at all. More... | |
constexpr bool | all (This_t bits) const |
Returns wether all bits are set. More... | |
constexpr bool | any (This_t bits) const |
Returns wether at least one of the bits is set. More... | |
constexpr bool | none (This_t bits) const |
Returns wether all bits are unset. More... | |
constexpr bool | only (This_t bits) const |
Returns wether no bits are set except (at most) the specified ones. More... | |
Bit change operations | |
void | set (This_t bits) |
Sets the specified bits. More... | |
void | unset (This_t bits) |
Unsets the specified bits. More... | |
void | keepOnly (This_t bits) |
Unsets the bits which are not in bits argument. More... | |
void | clear () |
Unsets all bits. More... | |
Bit manipulation operations returning a new object | |
constexpr This_t | select (This_t bits) const |
Returns only the bits that are also present in the argument. More... | |
constexpr This_t | exclude (This_t bits) const |
Returns only the bits that are not present in the argument. More... | |
constexpr This_t | combine (This_t bits) const |
Returns our bits, plus the ones present in the argument. More... | |
constexpr This_t | invert () const |
Returns all and only the bits that are not set. More... | |
Comparison operators for bits | |
constexpr bool | operator== (This_t other) const |
constexpr bool | operator!= (This_t other) const |
constexpr bool | operator< (This_t other) const |
constexpr bool | operator> (This_t other) const |
constexpr bool | operator<= (This_t other) const |
constexpr bool | operator>= (This_t other) const |
Static Public Member Functions | |
static void | setBits (Storage_t &base, Storage_t bits) |
Returns data with all bits from base and from bits set. More... | |
static void | onlyBits (Storage_t &base, Storage_t bits) |
static void | unsetBits (Storage_t &base, Storage_t bits) |
Returns data with all bits from base, but the ones from bits unset. More... | |
Public Attributes | |
Storage_t | data = { 0 } |
The bits representing all set bits. More... | |
Type identifying a set of bits.
using util::flags::Bits_t< Storage >::Flag_t = util::flags::Flag_t<Storage_t> |
using util::flags::Bits_t< Storage >::Storage_t = Storage |
using util::flags::Bits_t< Storage >::This_t = Bits_t<Storage> |
|
default |
Default constructor: no bit set.
|
inline |
Constructs from a single flag.
Definition at line 207 of file BitMask.h.
|
inlineexplicit |
Constructs from a set of bits.
Definition at line 212 of file BitMask.h.
constexpr bool util::flags::Bits_t< Storage >::all | ( | This_t | bits | ) | const |
Returns wether all bits are set.
constexpr bool util::flags::Bits_t< Storage >::any | ( | This_t | bits | ) | const |
Returns wether at least one of the bits is set.
|
inline |
Unsets all bits.
Definition at line 251 of file BitMask.h.
constexpr This_t util::flags::Bits_t< Storage >::combine | ( | This_t | bits | ) | const |
Returns our bits, plus the ones present in the argument.
|
inline |
Returns whether there is no bit set at all.
Definition at line 220 of file BitMask.h.
constexpr This_t util::flags::Bits_t< Storage >::exclude | ( | This_t | bits | ) | const |
Returns only the bits that are not present in the argument.
constexpr This_t util::flags::Bits_t< Storage >::invert | ( | ) | const |
Returns all and only the bits that are not set.
void util::flags::Bits_t< Storage >::keepOnly | ( | This_t | bits | ) |
Unsets the bits which are not in bits
argument.
constexpr bool util::flags::Bits_t< Storage >::none | ( | This_t | bits | ) | const |
Returns wether all bits are unset.
constexpr bool util::flags::Bits_t< Storage >::only | ( | This_t | bits | ) | const |
Returns wether no bits are set except (at most) the specified ones.
|
inlinestatic |
|
inlineexplicit |
Returns true if there is at least one bit set.
Definition at line 294 of file BitMask.h.
|
inline |
Returns true if there is no bit set.
Definition at line 297 of file BitMask.h.
|
inline |
Definition at line 280 of file BitMask.h.
|
inline |
Definition at line 282 of file BitMask.h.
|
inline |
Definition at line 286 of file BitMask.h.
|
inline |
Definition at line 278 of file BitMask.h.
|
inline |
Definition at line 284 of file BitMask.h.
|
inline |
Definition at line 288 of file BitMask.h.
constexpr This_t util::flags::Bits_t< Storage >::select | ( | This_t | bits | ) | const |
Returns only the bits that are also present in the argument.
void util::flags::Bits_t< Storage >::set | ( | This_t | bits | ) |
Sets the specified bits.
|
inlinestatic |
void util::flags::Bits_t< Storage >::unset | ( | This_t | bits | ) |
Unsets the specified bits.
|
inlinestatic |
Returns data with all bits from base, but the ones from bits unset.
Definition at line 310 of file BitMask.h.
Storage_t util::flags::Bits_t< Storage >::data = { 0 } |