Proposal: Aggregate member initialization

43 views
Skip to first unread message

Peter Kasting

unread,
Jan 9, 2018, 4:45:55 PM1/9/18
to cxx
(Last one from me for the foreseeable future, I promise!  Sorry, I've been meaning to propose a bunch of these for a while and got backlogged.)

C++14 allows structs with default member initializers to be initialized with aggregate initialization.  This thread proposes to allow this.

This seems relatively uncontroversial to me; while I can see debates as to whether this improves readability in specific cases, I can't see a reason to ban it outright.  It would primarily be useful in unittests, when initializing an array of structs (as a set of inputs to a test) where most of the inputs use a common value.


PK

Jeremy Roman

unread,
Jan 12, 2018, 10:50:02 AM1/12/18
to Peter Kasting, cxx
While I don't see this as an incredibly valuable feature (I have yet to be in a situation where I would have used this feature), I also don't see a strong reason to ban it (and, lacking enforcement, it will likely creep in regardless).

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFCi5HTZAD%2B3%3DfP%3Dw%2BkhwWGR8ST2yMZycNEfHc-aFNUENQ%40mail.gmail.com.

dan...@chromium.org

unread,
Jan 16, 2018, 12:07:14 PM1/16/18
to Jeremy Roman, Peter Kasting, cxx

Peter Kasting

unread,
Jan 18, 2018, 7:23:21 PM1/18/18
to cxx
This is allowed as of https://chromium.googlesource.com/chromium/src/+/f480c8c5324a677ee93bff1bc8a43f5bba72942b (though rebasing got things out of alphabetical order, which I'll fix in an upcoming patch).

PK
Reply all
Reply to author
Forward
0 new messages