C/C++ Bit Array or Bit Vector

I think you’ve got yourself confused between arrays and numbers, specifically what it means to manipulate binary numbers. I’ll go about this by example. Say you have a number of error messages and you want to return them in a return value from a function. Now, you might label your errors 1,2,3,4… which makes sense … Read more

Why isn’t vector a STL container?

For space-optimization reasons, the C++ standard (as far back as C++98) explicitly calls out vector<bool> as a special standard container where each bool uses only one bit of space rather than one byte as a normal bool would (implementing a kind of “dynamic bitset”). In exchange for this optimization it doesn’t offer all the capabilities … Read more