Repository navigation
C.45: drop 'only' from the rule title - #2337
Open
simoes-tiobe wants to merge 1 commit into
Open
simoes-tiobe wants to merge 1 commit into
simoes-tiobe wants to merge 1 commit into
Conversation
The title's wording ('a default constructor that only initializes
data members') reads as scoping the rule to constructors whose entire
body does nothing but initialize. The Enforcement clause is already
narrower and per-initializer ('Flag if a default constructor's
explicit member initializer is a constant'), so a constructor with an
extra body statement, or with one initializer that can't be moved
(e.g. a base subobject needing a non-default initializer), should
still have its other movable initializers flagged. Dropping 'only'
removes the misleading implication without changing the Enforcement
text.
Contributor
|
Editors call: Thanks! We agree that C.45's Enforcement doesn't match the title and body, which are about using the compiler generated default constructor when you can. We think the Enforcement should be moved to C.48 which covers the individual member initializer case, and C.45 should get a new Enforcement that focuses on using the compiler generated constructor when using member initializers makes that possible. I'll propose a new PR for this. Thanks for pointing this out! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The title of C.45 reads:
Taken literally, "only" scopes the rule to constructors whose entire body does nothing but initialize — i.e. it suggests the constructor is disqualified as soon as it does anything else, or has any initializer that can't become a default member initializer.
But the Enforcement clause is already narrower and per-initializer:
That is, each movable initializer should be flagged on its own merits, independent of the rest of the constructor. For example:
Under the current title's "only" reading,
Y's constructor could be misread as exempt (it does more than trivially initialize, sinceBase{7}requires an argument). Under the Enforcement clause as written,i{1}should still be flagged.This PR drops "only" from the title (TOC entry and section heading) so the title no longer implies a whole-constructor, all-or-nothing scope that the Enforcement text doesn't actually require. No other wording changes.