The standard, for the best of intentions, decided that vector<bool> should be specialized in order to be implemented as a bit set.
The bit set is fast enough, and you also have a choice of std :: bitset, which is a fixed size, and boost::dynamic_bitset , whose size is set at runtime, and in any case built on top of vector<unsigned int> This could be a template of which integral type is used).
It makes no sense to optimize further in order to save you a bit, so the proposal will be to use one of them.
By the way, I saw "scattered" bitmaps in which, if the value falls within a certain range, it uses one, otherwise it will use a tree-style search. (This method can also be used for Z-table functions (the usual type of CDF distribution), where you "cache" a table in memory of up to 95% or 99% of the density and use slow calculation for extreme values ββ(and I really had to do this) .
Cashcow
source share