Class A defines all copy/move constructor/assignment as follows:
struct A
{
std::string s;
A() : s("test") { }
A(const A& other) : s(other.s) { std::cout << "Copy constructor\n";}
A(A&& other) : s(std::move(other.s)) { std::cout << "Move constructor\n";}
A& operator= (const A& other) { std::cout << "Copy assignment\n"; s = other.s; return *this;}
A& operator= (A&& other) { std::cout << "Move assignment\n"; s = std::move(other.s); return *this;}
};
And the followings are functions returning an object of type A:
A f(A a) { return a; }
A g() { return A(); }
The main()
function is this:
int main()
{
A a1 = f(A()); // Move-construct
A a2 = std::move(a1); // Move-construct
A a3 (std::move(a2)); // Move-construct
A a4 (a1); // Copy-construct
A a5 = a4; // Copy-construct
a5 = f(A()); // Move constructor + Move assignment
a5 = a4; // Copy assignment
a5 = g(); // Move assignment
A a6 = g(); // None!! Member-wise assignment (?)
}
Can anybody tell me, why on earth none of the constructors and assignment operators is called for a6
? Which part of C++11's documentation describes this behavior?