Does RVO work on object members?
问题 Consider the following: struct A { /* ... */ }; A foo() { auto p = std::make_pair(A{}, 2); // ... do something return p.first; } auto a = foo(); Will p.first be copied, moved or RVO-ed? 回答1: I've found in Visual Studio 2010 and in gcc-5.1 RVO is not applied (see for example http://coliru.stacked-crooked.com/a/17666dd9e532da76). The relevant section of the standard is 12.8.31.1 [class.copy]. It states that copy elision is permitted (my highlighting): in a return statement in a function with a