Skip to content

US056 09.03 [dcl.init] Revert P0960 (parenthesized initialization of aggregates) #55

@wg21bot

Description

@wg21bot

C++20 intends to support parenthesized initialization of aggregates (eg, StructWithThreeElements(1, 2, 3)). The support for this also permits dropping trailing elements (eg, StructWithThreeElements(1)). Function-style casts from a single element are by definition equivalent to C-style casts, so this also unintentionally and problematically permits (StructWithThreeElements)1 and static_cast<StructWithThreeElements>(1).
In addition, while the problem this feature is trying to address is real (container emplace is not sufficiently general), this change only tackles a corner of the problem (only aggregates), and in so doing, further increases the complexity of C++ initialization. This problem should be addressed by a big-picture consideration of C++ initialization; something like lazy parameters are probably the right way to provide clean simple syntax for a generalized emplace.

Proposed change:
Revert the application of P0960R3.
Even without the more general concerns about this feature, we do not have any confidence that a different change to initialization, designed at the last minute, will do any better than P0960 did, so we should not attempt to repair it, and should instead reconsider ways to tackle the problem for C++23.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CWGCorerejectedNo consensus for a change.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions