开发者

Are Bitsets actually Bools?

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::bitsets 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜