2 ms·
Basically like an enum? It's not that weird. It does not need to use a storage of one bit, just like C chars can technically be larger than eight bits. I suspec
by jchw 4y ago
Basically like an enum? It's not that weird. It does not need to use a storage of one bit, just like C chars can technically be larger than eight bits. I suspect a bigger reason that boolean is missing from C is simply because C can't offer much additional value for boolean in its type system.
C++ can obviously do more with boolean types because it's got a more advanced type system, like disallowing values other than true and false to be assigned in code that only uses defined behavior. Boolean itself can take up whatever size the compiler decides it does, same idea as C. But, template types can special case boolean to use bitfields and allow for more space-efficient operations.