In C++, are bitsets actually a set of bools? Doesn't this defeat开发者_开发技巧 the purpose of using a BitSet because bools are 32 bits (I think...)?
They represent a collection of bool
's, but those values are really stored as bits in an unsigned long
.
The size of a bool
is not necessary any number of bits, neither is an unsigned long
. (Though the minimum number of bits for any data type is 8, and for an unsigned long
it must be at least 32.)
No, std::bitset
s are not actually bools, they are actually bitsets. Who told you that they were bools?
Are you perhaps getting confused with the controversy over std::vector<bool>
? Which is, incidientally, the opposite issue, since it looks like a set of bools but is actually a bitset.
精彩评论