Some operators, such as && and || perform a short circuit assessment. In addition, when a function is called with arguments, all arguments are constructed before the function is called.
For example, take the following three functions
bool f1(); bool f2(); bool f3(bool, bool);
if i call
if( f3(f2(),f1()) )
Then the return value of both f2 and f1 is evaluated before calling f3 . But if I used the (regular) operator|| instead of f3 than the previous code would be equivalent
if( f2()||f1() )
and f1 will not be evaluated if f2 is true.
My question is: is it possible that f3 (a user-defined function with two Boolean) behaves the same? If not, what does operator|| so special?
source share