|
Boost : |
Subject: Re: [boost] suggestion on assertion macros
From: Peter Dimov (pdimov_at_[hidden])
Date: 2010-03-12 16:11:55
Steven Watanabe:
> AMDG
>
> Roland Bock wrote:
>> Stewart, Robert wrote:
>>> C4800 seems ridiculous. Writing code using int as a Boolean is common
>>> to C code. Why would VC 9 inflict useless noise when compiling such
>>> code? Besides, if the variable is int, and it is needed in a Boolean
>>> context, what else would the developer do? I've seen use of the
>>> conditional operator to avoid that warning. I suspect that produces
>>> worse code than what is done when "forcing value to bool 'true' or
>>> 'false'."
>>>
>> I agree. Still, I hope that static_cast is allowed to remove C4800
>
> Nope.
>
> .\scratch.cpp(20) : warning C4800: 'int' : forcing value to bool 'true' or
> 'false' (performance warning)
C4800 is avoided with expr? true: false. In this case, sizeof( expr? 0: 0 )
will also work, as we don't care about the value.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk