c++ - Initializer list *argument* evaluation order -
Therefore, the C ++ standard requires that class members be started in that order in which they have been declared in the class The order is mentioned in any manufacturer's initial list. However, it does not show anything about the order in which the arguments for those initials have been assessed. I am working with the system which repeatedly passes in terms of the serialization objects, and thinking whether I can ensure that bits are read in the correct order, in which the bits are written in the field of the object Are there. P>
struct foo {int a; Double b; // I want to be able to be in this foo (sorrow and s): b (s.readDouble ()), a (s.readInt ()) {} // {B = s instead of the Fu (SOURGES AND S) .readDouble (); A = s.readInt (); }};
Obviously, sorting things like ints
and doubles
in the declaration is not a big deal, but large objects and things Dynamic allocation can sometimes happen.
C ++ standard 12.6.2 / 3
:
There is a sequence point (1.9) after the beginning of each base and member. The expression-list of mail-initialization is evaluated as the initial part of that base or member.
The sequence of initialization is specified in your question. Assessment is part of this initialization, and can not initially interfere (because there is a sequence point between them).
This means that the function call is not called in the desired order in your initial list, but member declarations appear in that order.
Comments
Post a Comment