A bool, by definition, in just about any language there is, always takes up the amount of space of the lowest addressable memory unit, which is 8 Bit (excluding some special, outdated architectures where you can access single bits directly). C++ is the only language I know of where a data type using bool uses single bits for storing them. Is it more efficient? Yes. But it breaks the universally accepted standard. Consistency is far more important than minimal efficiency improvements. Just add a seperate data type for when you really need that efficiency into the standard library.
View all comments
Show parent comment
10
u/_killer1869_ 10d ago
A bool, by definition, in just about any language there is, always takes up the amount of space of the lowest addressable memory unit, which is 8 Bit (excluding some special, outdated architectures where you can access single bits directly). C++ is the only language I know of where a data type using bool uses single bits for storing them. Is it more efficient? Yes. But it breaks the universally accepted standard. Consistency is far more important than minimal efficiency improvements. Just add a seperate data type for when you really need that efficiency into the standard library.