3 ms·
It's part of C++20 but is an extension borrowed from C in most C++11 compilers. I've been able to do it in g++ for at least 7 years now. The combination of ty
by CoolGuySteve 7y ago
It's part of C++20 but is an extension borrowed from C in most C++11 compilers. I've been able to do it in g++ for at least 7 years now.
The combination of type inference, pass by reference, and aggregate initialization shown here is only possible in C++, I think.
https://en.cppreference.com/w/cpp/language/aggregate_initialization https://en.cppreference.com/w/cpp/language/aggregate_initial...
- saagarjha 7y agoOoh, it nice to see that it's been officially added!
- alexhutcheson 7y agoNote that what's been added is a subset of the C99 behavior - there are a bunch of things that work in C99, but are not allowed (and might introduce undefined behavior) in C++20. See the "Design Decisions" section of this document for a summary of differences: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0329r0.pdf http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p032...
- flohofwoe 7y agoThe C99 designated initialization (where you give member names in the initialization) AFAIK only works in clang when compiled in C++ mode, gcc and MSVC doesn't appear to support it. C++20 will get a fairly limited subset of the C99's designated init though.