I have seen a kind of "poetic" code in some code base. Though it looks straight forward, just want to confirm, if it's in right direction.
In a very simple form:
bool foo ();
bool bar ();
int main () {
foo() or bar(); // <--- line
}
Is the code at highlighted line as good as below snippet?
if(foo() == false)
bar();
I am aware of , operator where all the statements are invoked, but unsure about or (equivalent to ||) operator.
Testing in g++, it gives expected output.
exp1 || exp2is nearly the same. The only thing missing is the unusedexp2result, which in both cases is thrown out anyway (if it is reached in the first place, which only happens withexp1is zero-equivalent).