There is a difference between the general notion of “boolean” that you ask about, and the C++ type bool
.
A bool
that is not a bitfield is minimum 1 byte, i.e. sizeof(bool)
≥ 1. This limit is because a byte is the minimum addressable unit; any C++ object is at least 1 byte. The standard does not place any upper limit on the size of bool
, but in practice it will not be larger than can be handled with single memory read and write operation.
A boolean variable is any variable used to implement the notion of boolean. There are a lot of boolean types around, not just C++'s own bool
. E.g., in Windows programming you have a BOOL
type that's more than one byte, and that in some cases can represent logical true via any non-zero value.
And in some cases, with a collection of boolean values they can be represented with just 1 bit each, for example in a std::bitset
or in a std::vector<bool>
(which is special-cased for the item type bool
in order to allow this). Or, I believe, but I haven't checked if that's supported, with a bitfield of size 1 of type bool
. And these considerations means that the question is a bit too vague to have a simple and crisp answer. If you'd asked about sizeof(bool)
it would have been much more clear-cut: just 1 or more bytes, depending on the implementation.