lundi 18 mars 2019

ISO: bit-mask manipulation library for C++ std::bitset<> for extracting/un-packing or setting values by striding over buffers or long CPU registers

For example, if a buffer contained 3 unsigned short ints, it would be able to one extract each value into a separate variables using & (bitwise and). Alternatively, it could load such a buffer. The buffer and the values should not be limited to enum_types, since they would be too small for large buffers. It could the the bitset<> type.

bitset<3*16> data {0xffffaaaacccc};
bitset<3*16> mask {0x0000ffff0000};
bitset<3*16> value {data&mask};  // contains 0x0000aaaa0000
auto value = my_value.to_ullong());

Any assistance in finding such a library would be appreciated.

Aucun commentaire:

Enregistrer un commentaire