Reputation: 9033
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...)?
Upvotes: 1
Views: 314
Reputation: 503795
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.)
Upvotes: 8
Reputation: 76650
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.
Upvotes: 6