Originally posted by marrub
-
P0329R4 Designated initializers
Much the opposite of the previous bullet-point, designated initializers have existed in C for literal decades and have never made their way back into C++. This is for a good reason; the rules for them are horrifyingly complex and don't mesh with C++ at all. Thankfully, Vulkan exists now, and abuses the fuck out of designated initializers. So now that there's finally a push to add them, the committee has figured out a decent compromise between C's extremely powerful and elder-god-invoking designated initializers and C++11's new brace style initializer syntax.
Here's an example of what you can do with it:
struct point {float x, y, z;}
point p{.x = 3.0, .y = 4.0};
distance({.x{}, .z{5.0}}, p);
finallyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
watch them remove it again because constructors
(and too bad I still need to support C++11)
EDIT wait it doesn't include arrays, ugh ("Array designators conflict with lambda-expression syntax") So much for my enthusiasm
|