This compiles and calls the copy constructor:
struct foo {
foo() = default;
foo(const foo&) { cout << "copy ctor!" << endl; }
//foo(const foo&&) = delete;
};
int main() {
foo a;
foo b(move(a));
This does not compile:
struct foo {
foo() = default;
foo(const foo&) { cout << "copy ctor!" << endl; }
foo(const foo&&) = delete;
};
int main() {
foo a;
foo b(move(a));
I know in the first case why the copy is called - the move ctor is not generated. But why doesn't the second snipper compile? It thought it would call the copy ctor again.
here is a link to an online compiler