Skip to content

Why I must overload operator false? #7671

Answered by CyrusNajmabadi
zms9110750 asked this question in Q&A
Discussion options

You must be logged in to vote

If you overload operator true then usages in || will properly short circuit. If you overload operator false then usages in && will properly short circuit. If you don't overload operator false then shortcircuiting will not work properly. That could lead to confusion where || works as one expects, but && does not.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@zms9110750
Comment options

@CyrusNajmabadi
Comment options

Answer selected by CyrusNajmabadi
@huoyaoyuan
Comment options

@zms9110750
Comment options

@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants