In particular, let's say I have:
struct X { X(int i) { cout << i; } };
int f() { cout << 'f'; return 0; }
int g() { cout << 'g'; return 1; }
struct Z {
Z() : a(f()), b(g()) {}
X a, b;
};
int main() { Z z; cout << '\n'; }
I know that element constructors are guaranteed to be called in the order in which they are defined in struct, so it 0will be printed before 1. But what about evaluating their arguments? Is it guaranteed:
f0g1
? Or maybe
fg01
and
gf01
are also valid outputs?
References to the standard are appreciated.
source
share