No, the C++ specification is such that it always evaluates conditions in a
lazy manner from left to right.

Persuter

At 11:51 PM 6/8/2003 +0200, you wrote:
You cannot assume that it is not evaluated. Maybe the compiler compiles the
code is such a way both get checked anyways. Or maybe the compiler copiles
it so the second statement gets checked first. You -never- know for sure, so
you should be explicit about it. I would do it this way (please note I use
NULL instead of using !, because strictly taken, you should always check
pointers with NULL. I think gcc even complains about it.)

if (pPlayer == NULL)
{
    // Do the code
}
else
{
    if (!pPlayer->IsNetClient())
    {
        // Do the code here too
    }
}

This structure is a bit odd, beacouse you have the code twice. So you should
use a function there. If you want to avoid using a function, just figure out
a different way to write the check (there always is a way to do it). Just
make sure you never try "pPlayer->IsNetClient()" if pPlayer is NULL.

Jeroen "ShadowLord" Bogers

_______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders



Reply via email to