Flow123d
DF_patch_fe_data_tables-32b3de9
|
std::bitset with generalized mask mechanism. More...
#include <flag_array.hh>
Classes | |
class | Mask |
Public Member Functions | |
FlagArray () | |
Default constructor turns all flags off. More... | |
FlagArray (Mask mask) | |
Conversion from the mask. More... | |
constexpr bool | match (Mask mask) const |
FlagArray & | add (Mask mask) |
Static Public Attributes | |
static const unsigned int | size = Size |
Allocated size of flags storage. More... | |
static constexpr Mask | all_true_mask =Mask(~BitField(0), ~BitField(0)) |
static constexpr Mask | all_false_mask =Mask(~BitField(0), BitField(0)) |
static constexpr Mask | none_mask =Mask(0, 0) |
Private Types | |
typedef unsigned int | BitField |
Declaration of internal bitfield type. More... | |
Private Attributes | |
BitField | flags_ |
flags storage More... | |
Friends | |
constexpr friend bool | operator== (FlagArray left, FlagArray right) |
bool | operator!= (FlagArray left, FlagArray right) |
std::ostream & | operator<< (std::ostream &s, const FlagArray &f) |
std::bitset with generalized mask mechanism.
The drawback of classical bitfield technique implemented e.g. in std::bitset<> is problematic work (set and test) with more bits then one at time. This class is simple wrapper for std::bitset<> that provides public class FlagArray<..>::Mask that represents some bit subset together with a reference value which can be used to set the bit subset or to test the bit subset.
The class is meant to be used in several other classes, that can define their specific masks. Every class using the FlagArray should provide specific Tag
template parameter in order to guarantee Mask - FlagArray compatibility.
Implementation note: since std::bitset do not have constexpr operators (may be in c++1y) we currently use just unsigned int in our implementation.
Usage:
Definition at line 48 of file flag_array.hh.
Declaration of internal bitfield type.
Definition at line 52 of file flag_array.hh.
Default constructor turns all flags off.
Definition at line 139 of file flag_array.hh.
Conversion from the mask.
Definition at line 144 of file flag_array.hh.
Apply the mask to the flags. Bits by the mask.mask_
are overwritten by the mask.set_
values.
Definition at line 170 of file flag_array.hh.
|
inlineconstexpr |
The FlagArray match a mask if and only if bits given by the mask.mask_
are same in both the flags_ and mask.set_.
Definition at line 163 of file flag_array.hh.
|
friend |
Definition at line 154 of file flag_array.hh.
|
friend |
Definition at line 173 of file flag_array.hh.
|
friend |
Definition at line 150 of file flag_array.hh.
|
staticconstexpr |
Definition at line 132 of file flag_array.hh.
|
staticconstexpr |
Definition at line 131 of file flag_array.hh.
flags storage
Definition at line 179 of file flag_array.hh.
|
staticconstexpr |
Definition at line 133 of file flag_array.hh.
|
static |
Allocated size of flags storage.
Definition at line 129 of file flag_array.hh.