struct A { A(int x) : n(x) {} A(A&&) {} A& operator =(A&&) { return *this; } int n; }; int main() { A a(1), b(2); a = b; if (2 == an) {
According to C ++ 12.8.7 standard:
If the class definition declares a move constructor or transfers an operator assignment, an implicitly declared copy constructor is defined as excluded;
and 12.8.18
If the class definition declares a move constructor or transfers an operator assignment, the implicitly declared copy assignment operator is determined as deleted;
The operator a = b; should cause a compiler error. However, my compiler (VC ++ 2013 RC) accepts it and invokes an implicit copy job instead.
Is this a compiler error?
Update:
I presented this problem as a bug in microsoft .
c ++ compiler-construction copy-constructor c ++ 11 deleted-functions
xmllmx
source share