|
bit_logic > Concepts > Bit Storage
Bit StorageBit Storage concept refers to any type in the C++ type system or Standard Library, where operations on its binary data is defined, and for which access to any bit is constant. For instance bit 3 of uint8_t can be set by oring it withe the value 1 left shifted by 3. Because the C++ Standard defines unsigned integral types to be exactly 2n bit representations, we can use any unsigned integral type as Bit Storage. Contiguous containers of unsigned integral types can also be used to store bit sizes greater than the maximum available unsigned integral type. In these cases, the bit index is defined as being bit_offset_in_word + word_offset * bits_per_word A restriction is also placed on Bit Storage types, that their size information needs to be defined. For this reason pointers are not an acceptable form of Bit Storage, but arrays are. Examples of valid Bit Storage types:
Examples of types that can not be used as Bit Storage:
|