Visual C ++は戻り値の最適化を実行しませんか?
#include <cstdio>
struct Foo { ~Foo() { printf("Destructing...\n"); } };
Foo foo() { return Foo(); }
int main() { foo(); }
私はそれをコンパイルして実行します:
cl /O2 test.cpp
test.exe
そしてそれは印刷します:
破壊する...
破壊する...
なぜRVOを実行しないのですか?