isocpp / isocpp/CppCoreGuidelines
[C++20] C.86: Make == symmetric with respect to operand types
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
[intentionally ignoring "and noexcept" because it's unrelated]
As far as I understand, with C++20 rewritten expressions, an operator== defined as a member function is now symmetric and the assertion
B’s comparison accepts conversions for its second operand, but not its first.
in the guidelines does not hold anymore.
I would still teach people to define their operators as non-member because other operators are not symmetric and it's easier to have just one general rule "define operators as non-member functions".
But is my understand correct here ? If it is, do you agree we should change the wording of C.86 ?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the current wording of guideline C.86 and the C++20 rules for rewritten comparison expressions. Confirm whether the stated asymmetry still applies, then determine whether the guideline needs revised wording. Done means the language-lawyer question is resolved and C.86 accurately reflects the decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100