-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XOR operator '^' for bools #22740
XOR operator '^' for bools #22740
Conversation
How is this different from |
The code could be simplified with I don't mind adding this, but I also don't see much use case since |
Given that the other bitwise operators don't work on booleans, I would prefer to have a special boolean-xor operator than that (e.g. |
Well then I'd prefer none at all if it's the same as |
I made this PR merely for training c++. The addition of this little feature seemed like a good task to me. I know that this is not a necessary feature. If you don't want to add |
Even though logically it is the same as !=, at least in my case sometimes conceptually they seem different or are recognized more immediately in certain context. Not equal and one or the other. Check if these are not equal. Though redundant I wouldn't mind Something like: |
If this is really needed we could add |
Most languages don't have an logical xor operation and just use the bitwise xor. The ones that actually have an logical xor usually just overload And I wouldn't go through the hassle of adding a new 'xor' operator, token and all unless there were a decent amount of people requesting the feature. |
As per the above discussion, I don't think this is a useful addition for now, since it doesn't have any practical use case nor strong community involvement to get it nevertheless. I'll also close the original feature request as such. Thanks for working on it and pushing the discussion forward though! |
closes #18816
The bitwise xor operator (^) has been extended to also work as an logical operation.