|
Boost Users : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2005-11-13 06:45:14
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). I don't think you could really "assert" for this
because you can't trust "assert" (since you can't trust the compiler)! If
the "bool" was uninitialized before the conversion, then you have undefined
behavior and the not-0-nor-1 result is the least of your problems.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT 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