I need a minimum size implementation of an array of bools. The size of the array is known at compile time.
I checked std::bitset and boost::array, but they both incur an overhead that is significant for small arrays. For example, if the array size is 8, the container should only use 1 byte of memory (assuming common CPU architecture).
Does this exist or do I need to roll my own?
std:bitsetshould only use one bit per element (asstd::vector<bool>does in some implementations). How did you check that it uses more?sizeof(std::vector<bool>)it returns 40std::vector<bool>weights 40 bytes even when empty). It does not take into account the heap memory allocated for the elements themselves.