Is the order for variadic template pack expansion defined in the standard?

非 Y 不嫁゛ 提交于 2019-12-04 09:33:41

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!