Skip to content

Apply Oct 1 editors call suggestion - #2339

Open
hsutter wants to merge 1 commit into
masterfrom
c45
Open

hsutter wants to merge 1 commit into
masterfrom
c45

Conversation

@hsutter

@hsutter hsutter commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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.

Comment thread CppCoreGuidelines.md
##### 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants