3 ms·
In a C++ designated initialization, members may be omitted. (You were told wrong.) There is probably no reason to enforce order unless unmentioned elements hav
by ncmncm 7y ago
In a C++ designated initialization, members may be omitted. (You were told wrong.)
There is probably no reason to enforce order unless unmentioned elements have a non-trivial destructor, so that could be relaxed in a future Standard. Members that need destruction would need to be destroyed in the opposite order; enforcing order allows reusing code already generated for the containing-object destructor, but in many interesting cases (e.g. C structs) there are no destructors to run anyway. In the others, there is no reason why it would need to re-use the class destructor.
- wahern 7y agoI stand corrected, thank you. For posterity (I like to leave breadcrumbs for myself): https://github.com/cplusplus/draft/blob/dc2bff0/source/declarations.tex#L4614 https://github.com/cplusplus/draft/blob/dc2bff0/source/decla... https://github.com/cplusplus/draft/blob/dc2bff0/source/declarations.tex#L4693 https://github.com/cplusplus/draft/blob/dc2bff0/source/decla... https://github.com/cplusplus/draft/blob/dc2bff0/source/compatibility.tex#L586 https://github.com/cplusplus/draft/blob/dc2bff0/source/compa...