Search code examples
c++c++11movervalue-reference

What's the difference between "doesn't synthesize" and "defined as deleted"?


I read C++ Primer 5th, and found move constructor and move assignment confusing.

On one page, it says:

The compiler synthesizes the move constructor and move assignment only if a class does not define any of its own copy-control members and only if all the data members can be moved constructed and move assigned, respectively.

On another page, it says:

If we explicitly ask the compiler to generate a move operation by using = default, and the compiler is unable to move all the members, then the move operation will be defined as deleted.

Is there any difference between "doesn't synthesize" and "will be defined as deleted"?


Solution

  • A function defined as deleted still participates in overload resolution; if selected, the program is ill-formed. If a function does not exist at all, it of course doesn't participate in overload resolution.