forcing evaluation in if()
Pragma
ericanderton at yahoo.removeme.com
Fri Nov 17 09:41:54 PST 2006
Antonio wrote:
>
>> Yup. I just assumed the operands were bools in the first place..
>>
>> Other workarounds include
>>
>> cast(bool)a & cast(bool)b
>> !!a & !!b
>> a?b?1:0:b?0:0 // just kidding
Actually, for the "follows" operation, isn't that the same as:
auto x = a; // evaluate a
if(x ? b : !x){
// do something
}
It makes me wonder if the '?' could be granted a shorthand to cover this?
Something like:
a ? b
Which would be the same as:
a ? b : !a
Only without the redundant evaluation of a.
--
- EricAnderton at yahoo
More information about the Digitalmars-d
mailing list