c++copy-constructordefault-constructormove-constructormove-assignment-operator

Conditions for automatic generation of default/copy/move ctor and copy/move assignment operator?


I want to refresh my memory on the conditions under which a compiler typically auto generates a default constructor, copy constructor and assignment operator.

I recollect there were some rules, but I don't remember, and also can't find a reputable resource online. Can anyone help?


Solution

  • In the following, "auto-generated" means "implicitly declared as defaulted, but not defined as deleted". There are situations where the special member functions are declared, but defined as deleted.

    C++11 and later only: