How should I work with arrays of nibbles/quarter-bytes?

时间:2016-06-10 10:03:52

标签: c++ arrays c++-standard-library nibble

I find myself needing to work with "arrays" of elements of size 1/2 , or 1/4 - i.e. "arrays" of nibbles or quarter-bytes, packed together within bytes (according to some endianness choice).

I know the standard library has the (unfortunate?) std::vector<bool> specialization (and Boost has dynamic_bitset), but I want an abstraction better fitting my actual element sizes rather than individual bits. If push comes to shove I may implement a pseudo-container with proxy objects, but I would rather avoid having to do that myself if there's a reasonable alternative. Is there? Specifically, does the standard library has any relevant facility I could use?

Note: We're talking longer arrays whose length is not known at compile time.

0 个答案:

没有答案