Unfortunately, C/C++ are a little flexible in their definition of what constitutes a boolean value...
Well, as usual, the C++ committee took great care to avoid actually saying anything while saying a lot of things, but I think you can still deduct the de-facto definition from what they say. It's amazing how you can write 1,300 pages without laying something very simple down in a clear, understandable, non-ambiguous manner.
Values of type bool are either true or false.
A zero value, null pointer value, or null member pointer value is converted to false; any other value is converted to true.
Great. Very nice, except we don't know what true and false are. This isn't mentioned anywhere within those 1,300 pages. For all we know, false could be 354357 and true could be 77342.
However, in combination with this:
A prvalue of type bool can be converted to a prvalue of type int, with false becoming zero and true becoming one.
one can pretty much safely presume that false == 0 and true == 1, even though again it doesn't explicitly say so. Converting to bool and converting from bool converts to/from 0 and 1, respectively.
Of course, given this wording, it is still technically allowable to have different values and add extra code for conversion (similarly, it is perfectly allowable for a null pointer to be something different from zero, even though the literal zero explicitly converts to the null pointer).
But even though technically allowable, it's not something that really makes sense. The values 0 and 1 are as good as any other values, and they do not require extra code for a conversion that has no benefit.
Further, it is explicitly allowable to store a bool in a bit-field, and in this case no "implementation specific" value that isn't exactly 1 would work for true. Neither would (given only two possible values in a single bit) any other value but 0 work for false, since 1 is already taken.
Edited by samoth, 20 August 2013 - 05:19 AM.