struct Foo {
Foo(): { cout << "Default Ctor" << endl; }
Foo(const Foo& foo) { cout << "Copy Ctor" << endl; }
Foo(Foo&& foo) { cout << "Move Ctor" << endl; }
};
Foo test() {
Foo temp;
return temp;
}
int main() {
Foo f1; // Default Ctor
Foo f2(f1); // Copy Ctor
Foo f3(test()); // ????
return 0;
}
The f3
object is successfully created, but neither copy constructor nor move constructor is called.
How does this work?