Which clause in the C++11 Standard supports the move constructor call in the return of the function foo() below?
#include <iostream>
class A
{
public:
A() { std::cout << "Ctor\n"; }
A(const A&) {std::cout << "Copy ctor\n";}
A(A&&) {std::cout << "Move ctor\n";}
};
A foo(A&& ra) { return std::move(ra); }
int main()
{
A a = foo(A());
}
This question was closed I believe yesterday, now it was placed "on hold" and the reason for the closing was that it's too localized. It's difficult for me to understand how a post in SO asking a specific question about the C++11 Standard could be considered "too localized". For me this is a contradiction in terms, as the Standard is "de facto" the final document that every C++ programmer should look for, in case of doubt about the language.