Is the order for variadic template pack expansion defined in the standard?
Yes. The expanded elements are in an order that corresponds to the original order of the pack.
In the test, the expansion [](...){}(print(i++, args)...);
is equivalent to: [](...){}(print(i++, a), print(i++, b), print(i++, c));
.
The test is flawed in that it tests the order of evaluation of function arguments, which is a completely different matter. If you try and execute the expanded form presented above, you will observe the same behaviour. Or you would if the code didn't have undefined behaviour, since the variable i
is incremented several times without the increments being sequenced.