3 ms·
> A subset of designated initializers is supported in C++20. Took them only 21 years... And this standard being so recent, most projects won't have that for y
by yakubin 6y ago
> A subset of designated initializers is supported in C++20.
Took them only 21 years... And this standard being so recent, most projects won't have that for years to come.
- pjmlp 6y agoDoesn't matter, the point was what C subset does C++ support today. https://godbolt.org/z/GW59rM https://godbolt.org/z/GW59rM
- vitus 6y agoC++20 designated initializers must be specified in definition order, whereas they don't in C99. In your example, Point point = {.z = 2.0, .x = 1.0}; produces a compilation error. This is annoying, but workable. And at least it's a compile-time error, rather than a bug that perniciously sneaks into production.
- pjmlp 6y agoWhy do you think I wrote "A subset of designated initializers is supported in C++20."?