C++: why this simple Scope Guard works?

喜夏-厌秋 提交于 2019-11-30 19:36:00

You're observing the effects of Copy Elision (or Move Elision, in this case). Copy Elision is not guaranteed / mandatory, but usually performed by major compilers even when compiling w/o optimizations. Try gcc's -fno-elide-constructors to see it "break": http://melpon.org/wandbox/permlink/B73EuYYKGYFMnJtR

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