by adrian_b · 2w ago · 0 comments
This would solve your problem.
Nonetheless, I do not see why in any correct code the order of member initialization may be relevant, even when different initialization orders can produce different results, because the values of some members depend on the values of other members. If the destructor of some member accesses another member that may have already been destructed, or not, there must be a way to determine this, e.g. destructing a member should replace it with some default value for that type, e.g. a zero or a NaN or a null pointer.
Accessing other members that have already been destructed may happen also in other contexts than during the explicit initialization of the structure, so it must never lead to unpredictable behavior.