Am 14.11.2014 15:32, schrieb Love Nystrom:
On 2014-11-14 00.41, Alex Ionescu wrote:
I would much rather see if (f != FALSE) instead
of if ( f ).
Well, it's certainly a valid option, and C++ compilers seem to generate
the same "CMP boolRm, 0" in both cases (though the latter could actually
generate the potentially faster and better "OR boolRm, boolRm" instead).
"if (f != FALSE)" and "if (f)" are exactly 100% the same for the
compiler. "if (f)" is nothing but a synonym for "if (f != 0)" and
FALSE
is 0. Whether it creates a CMP, or an OR or a TEST is all up to the
compiler and it will be the same in both cases. If it was not the same,
there is something ... well not neccessarily "wrong" but at least very
strange with the compiler.
I expect some people will use the former.
Personally I much prefer the latter.
I think both have their pros and cons. So I
don't really care.