Here is the code: http://coliru.stacked-crooked.com/a/f7731b48747c61a9
#include <iostream>
struct A{
A(const A&){ std::cout << "A(const A&)" << std::endl;}
A(const A&&){ std::cout << "A(const A&&)" << std::endl;}
A(){ }
};
A foo(){
return *new A;
}
int main()
{
A a;
A c(foo());
}
Since, I passed to the c
's constructor argument a temporary object, I expected the move constructor to be called. But the copy constructor was. Why?