Does standard C++11 guarantee that temporary object passed to a function will have been created before function call?

我只是一个虾纸丫 提交于 2019-12-04 14:01:05

[intro.execution]/16:

When calling a function (whether or not the function is inline), every value computation and side effect associated with any argument expression, or with the postfix expression designating the called function, is sequenced before execution of every expression or statement in the body of the called function.

From [expr.call]/8 we have

[ Note: The evaluations of the postfix expression and of the arguments are all unsequenced relative to one another. All side effects of argument evaluations are sequenced before the function is entered (see 1.9). —end note ]

This means that all parameters are constructed before the function is entered.

Consequently this also guarantees that all parameters are destroyed after the function exits.

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