It says "Like the Copy-assignment operator, the move-assignment operator is defined as deleted if the class has a const or reference member." in C++ Primer 5th Section 13.6 .
And I write a demo like below.
#include <iostream>
class A {
public:
A() : mem(0) {}
const int mem;
};
int main()
{
A a1, a2 = std::move(a1);
return 0;
}
It has const member in class A but why it can be compiled successfully? What I missed?