-
Notifications
You must be signed in to change notification settings - Fork 4
Description
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.