|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-11-13 08:00:51
Daryle Walker <darylew_at_[hidden]> writes:
> On 11/10/05 11:21 AM, "David Abrahams" <dave_at_[hidden]> wrote:
>
>> "Robert Ramey" <ramey_at_[hidden]> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net