C++ Logo

std-proposals

Advanced search

[std-proposals] Are there any plans to allow opting in into designated initializers for my nonaggregate classes/structs?

From: Ivan Matek <libbooze_at_[hidden]>
Date: Thu, 18 Aug 2022 23:27:04 +0200
Often I encounter the following problem:
I am happily using the readability benefit of designated initializers in my
struct.
Then I notice I must add a functionality that makes it a nonaggregate (for
example deleting copy constructor to prevent accidental expensive copy),
then all my nice initialization must go away and I am forced to write a
spammy "forwarding" constructor (one that does nothing, just initializes
all variables with mathiing arguments).

I am not sure what syntax would be best, maybe
[[agg_init]]
attribute?

Received on 2022-08-18 21:27:13