1

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.

einpoklum
  • 118,144
  • 57
  • 340
  • 684

0 Answers0