
13 Nov
2005
13 Nov
'05
1 p.m.
Daryle Walker <darylew@hotmail.com> writes:
On 11/10/05 11:21 AM, "David Abrahams" <dave@boost-consulting.com> wrote:
"Robert Ramey" <ramey@rrsd.com> writes: [SNIP]
But a close substiture might be to convert the variable to an integer, throw an exception if its not equal to 0 or 1
No!! If you convert a bool to an integer and get something other than 0 or 1 then there's a bug in the program (or in the compiler). An assertion is appropriate. [TRUNCATE]
The bug would be in the compiler since other values are not allowed (see s4.5p4 and s4.7p4).
No, an bool that was left uninitialized could be converted into a different int value as one expression of undefined behavior. -- Dave Abrahams Boost Consulting www.boost-consulting.com