isocpp / isocpp/CppCoreGuidelines
C.60 and C.63: Should we allow `operator=` to return `void`?
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
We have;
- C.60: Make copy assignment non-
virtual, take the parameter byconst&, and return by non-const& - C.63: Make move assignment non-
virtual, take the parameter by&&, and return by non-const&
The only reason to require "return by non-const&" is to enable chaining (e.g., a=b=c;).
In recent conversations, I've heard sympathy for not requiring chaining and allowing a void return type from operator=. If so, we should consider changing the Guidelines to allow a void return from operator= so that code that does that won't get flagged by Guideline checkers.
Proposed solution: Changed the end of each the C.60 and C.63 titles to be "... and return by non-const& or void" and update the bodies similarly.
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 C.60 and C.63 entries linked in the issue, then read the eight-comment discussion about whether assignment chaining should remain required. Done means reaching a decision and updating both guideline titles and bodies to consistently address a void return, if accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100