Q
Qi
Hi all,
Below is some code to test the evaluation order in a function
calling chain.
On both VC and GCC, b(2) is called before b(1).
(but f(b(1)) is called before f(b(2)), as I expected).
My question is, is there any standard about the evaluation order
of b(1) and b(2)?
I guess it's up to the compiler to decide the order so the order
is not guaranteed left to right or right to left?
Or to say, can, or can not, I give any assumption on the order?
Thanks
struct A
{
A & f(int n) {
return *this;
}
};
int b(int n)
{
cout << n << endl;
return n;
}
void test()
{
A a;
a.f(b(1)).f(b(2));
}
Below is some code to test the evaluation order in a function
calling chain.
On both VC and GCC, b(2) is called before b(1).
(but f(b(1)) is called before f(b(2)), as I expected).
My question is, is there any standard about the evaluation order
of b(1) and b(2)?
I guess it's up to the compiler to decide the order so the order
is not guaranteed left to right or right to left?
Or to say, can, or can not, I give any assumption on the order?
Thanks
struct A
{
A & f(int n) {
return *this;
}
};
int b(int n)
{
cout << n << endl;
return n;
}
void test()
{
A a;
a.f(b(1)).f(b(2));
}