isocpp / isocpp/CppCoreGuidelines

C.60 and C.63: Should we allow `operator=` to return `void`?

Open
#1,988 8 comments 3 reactions 0 assignees View on GitHub

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;

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.