A bool
uses at least one (and maybe more) byte of storage, so yes, at least 8 bits.
A vector<bool>
, however, normally stores a bool
in only one bit, with some cleverness in the form of proxy iterators and such to (mostly) imitate access to actual bool
objects, even though that's not what they store. The original C++ standard required this. More recent ones have relaxed the requirements to allow a vector<bool>
to actually be what you'd normally expect (i.e., just a bunch of bool
objects). Despite the relaxed requirements, however, a fair number of implementations continue to store them in packed form in a vector<bool>
.
Note, however, that the same is not true of other container types--for example, a list<bool>
or deque<bool>
cannot use a bit-packed representation.
Also note that due to the requirement for a proxy iterator (and such) a vector<bool>
that uses a bit-packed representation for storage can't meet the requirements imposed on normal containers, so you need to be careful in what you expect from them.