Sign in to follow this  
Axiverse

Short Circuit

Recommended Posts

Yes. I'm not sure on how guaranteed that is, or in what cases it might fail, but I've always seen it work, and I've never seen people more knowledgable than me comment on it, making me suspect it is something guaranteed.

Share this post


Link to post
Share on other sites
Yes, it guaranteed by standards compliant C++ compilers. "...&& guarantees left-to-right evaluation; the second operand is not evaluated if the first operand is false." (Section 5.14 paragraph 1 in ISO/IEC 14882:2003)

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
Yes, it guaranteed by standards compliant C++ compilers. "...&& guarantees left-to-right evaluation; the second operand is not evaluated if the first operand is false." (Section 5.14 paragraph 1 in ISO/IEC 14882:2003)


Also I believe that, similarly, the || operator will not evaluate the second operand if the first is true.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this