Repository navigation
Conversation
bgloyer
reviewed
Oct 9, 2026
| ##### Enforcement | ||
|
|
||
| (Simple) Flag if a default constructor's explicit member initializer is a constant, and recommend that the constant should be written as a data member initializer instead. | ||
| (Simple) Flag if a default constructor only initializes members, and recommend that the initializers should be written as data member initializers instead and the compiler-generated default constructor used |
Contributor
There was a problem hiding this comment.
Should this be more resticted like "Flag if a default constructor only initializes members from simple expressions, ..."
I think these examples should not use data memeber initializers:
double a {cos(.1)}; // requires header for cos when it is only an implementation detail
MyType b {InternalFunction()}; // also requires implementaion to be known in header
time_point<system_clock> creationTime{ system_clock::now() }; // dynamic
creationTime example was in #2332
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.
In today's editor's call, we considered #2337 and responded: 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.
This PR makes those two changes. Accepting this PR closes #2337.