> not guaranteed but allowed by the language and widely implemented
Ome can make it guaranteed (assuming Foo is an aggregate) by writing:
Foo make_foo() {
return Foo{.blah = 7};
}
This guarantees initialization happens at the end of the function, since you are returning a pure rvalue. Generally a good style rule to adopt and no annotations needed.
Ome can make it guaranteed (assuming Foo is an aggregate) by writing:
This guarantees initialization happens at the end of the function, since you are returning a pure rvalue. Generally a good style rule to adopt and no annotations needed.Replies (2)
(except they’re right and you just gained +1 to wisdom)
Replies (1)
https://en.cppreference.com/cpp/language/aggregate_initializ...
Generally, when you're doing the
pattern, it's because Foo is a struct with only public members and no constructor used for passing data around. e.g. When it's that simple rather than type out: You'd type: Congrats the code is shorter!Replies (1)