Full-expression boundaries and lifetime of temporaries [duplicate]

拈花ヽ惹草 提交于 2019-11-29 06:28:52

Temporaries life until the end of the full expression in which they are created. A "full expression" is an expression that's not a sub-expression of another expression.

In baz(bar(...));, bar(...) is a subexpression of baz(...), while baz(...) is not a subexpression of anything. Therefore, baz(...) is the full expression, and all temporaries created during the evaluation of this expression will not be deleted until after baz(...) returned.

As the name suggests, the full-expression is all of the expression, including the call to baz(), and so the temporary will live until the call to baz() returns.

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