J
Juha Nieminen
IIRC for example when calling a function taking several parameters,
the order in which those parameters will be evaluated is not specified
by the standard. (In other words, if you write "f(a, b)" then b might
be evaluated before a.) This means that if I do this:
f(func1(), func2());
it's not guaranteed that func1() will be called first and func2() after
that. It may happen the other way around.
Is this also so with initializer lists? For example, if I initialize
a struct like this:
SomeStruct obj = { func1(), func2() };
is it guaranteed that func1() will be called first, and then func2()?
(I know that the elements of the struct will be initialized in order.
However, are the parameters to those elements also evaluated in that
same order?)
Likewise for an array:
int anArray[] = { func1(), func2() };
is it guaranteed that func1() will be called first, and then func2()?
(Also here the array elements are initialized in order, but does that
mean that the parameters are evaluated in the same order?)
How about C++11 initializer lists? Such as:
std::vector<int> aVector = { func1(), func2() };
the order in which those parameters will be evaluated is not specified
by the standard. (In other words, if you write "f(a, b)" then b might
be evaluated before a.) This means that if I do this:
f(func1(), func2());
it's not guaranteed that func1() will be called first and func2() after
that. It may happen the other way around.
Is this also so with initializer lists? For example, if I initialize
a struct like this:
SomeStruct obj = { func1(), func2() };
is it guaranteed that func1() will be called first, and then func2()?
(I know that the elements of the struct will be initialized in order.
However, are the parameters to those elements also evaluated in that
same order?)
Likewise for an array:
int anArray[] = { func1(), func2() };
is it guaranteed that func1() will be called first, and then func2()?
(Also here the array elements are initialized in order, but does that
mean that the parameters are evaluated in the same order?)
How about C++11 initializer lists? Such as:
std::vector<int> aVector = { func1(), func2() };