Is the following code safe if a null pointer is passed in?
if(ptr && *ptr == value) { //do something }
Does the order of the checks
The former is correct and safe, the latter is not.
The built-in && operator has short-circuit semantics, meaning that the second argument is evaluated if and only if the first one is true.
&&
(This is not the case for overloaded operators.)