Can returning a local variable by value in C++11/14 result in the return value being constructed by rvalue when no copy/move is involved?
问题 I know that in the following situation that the compiler is free to move-construct the return value from makeA (but is also free to elide the copy or move altogether): struct A { A(A&); A(A&&); }; A makeA() { A localA; return localA; } What I wonder is whether the compiler is allowed to construct an object of type A from a local object of type B by rvalue reference if it is being constructed in the return statement. In other words, in the following example, is the compiler allowed to select A