A Bitset implementation with inline storage that can grow if needed.
T is the storage type (uint8_t, uint16_t, uint32_t, uint64_t) N is the initial number of bits to store inline
#include <bitset.h>
Classes | |
struct | Proxy |
Public Member Functions | |
BitsetInlined () | |
Constructs a Bitset with all bits reset. | |
BitsetInlined (BitsetInlined &&other) noexcept | |
BitsetInlined (const BitsetInlined &other) | |
BitsetInlined (size_t size) | |
bool | all () const noexcept |
bool | any () const noexcept |
Queries. | |
void | assign (size_t n, bool value) |
uint32_t | count () const noexcept |
Returns the number of set bits. | |
BitsetInlined & | flip () noexcept |
Flips all bits. | |
BitsetInlined & | flip (uint32_t pos) |
Flips (toggles) the bit at position pos. | |
bool | none () const noexcept |
BitsetInlined & | operator= (BitsetInlined &&other) noexcept |
BitsetInlined & | operator= (const BitsetInlined &other) |
Proxy | operator[] (uint32_t pos) |
bool | operator[] (uint32_t pos) const noexcept |
Returns the value of the bit at position pos. | |
void | reset () noexcept |
Resets all bits to zero. | |
BitsetInlined & | reset (uint32_t pos) |
Clears the bit at position pos. | |
void | resize (uint32_t new_size) |
Resizes the Bitset if needed. | |
BitsetInlined & | set (uint32_t pos, bool value=true) |
Sets or clears the bit at position pos. | |
uint32_t | size () const noexcept |
Size of the Bitset (number of bits). | |
bool | test (uint32_t pos) const noexcept |
Tests whether the bit at position pos is set. | |
Private Types | |
using | fixed_bitset = BitsetFixed<N> |
Private Attributes | |
Variant< fixed_bitset, bitset_dynamic > | _storage |
Friends | |
BitsetInlined | operator& (const BitsetInlined &lhs, const BitsetInlined &rhs) noexcept |
BitsetInlined | operator^ (const BitsetInlined &lhs, const BitsetInlined &rhs) noexcept |
BitsetInlined | operator| (const BitsetInlined &lhs, const BitsetInlined &rhs) noexcept |
BitsetInlined | operator~ (const BitsetInlined &bs) noexcept |
Bitwise operators. | |