Isn't return value optimization (RVO) a bug?

前端 未结 3 1643
予麋鹿
予麋鹿 2020-12-10 16:36

I maybe asking a dumb question, but I looked at the wikipedia page for RVO here and could not stop wondering if that behavior is wrong. I tried it in my machine and RVO is f

3条回答
  •  没有蜡笔的小新
    2020-12-10 16:40

    The standard mandates that operations with concern a program's observable state must not be optimized away, except for copy construction in certain circumstances. You must not rely on copy constructors to be executed, even if they have side effects you expect to see (e.g., console output).

提交回复
热议问题