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


i want refresh memory on conditions under compiler typically auto generates default constructor, copy constructor , assignment operator.

i seem recollect there rules, don't remeber, , can't find reputable resource online. can help?

in following, "auto-generated" means "implicitly declared defaulted, not defined deleted". there situations special member functions declared, defined deleted.

  • the default constructor auto-generated if there no user-declared constructor (§12.1/5).
  • the copy constructor auto-generated if there no user-declared move constructor or move assignment operator (because there no move constructors or move assignment operators in c++03, simplifies "always" in c++03) (§12.8/8).
  • the copy assignment operator auto-generated if there no user-declared move constructor or move assignment operator (§12.8/19).
  • the destructor auto-generated if there no user-declared destructor (§12.4/4).

c++11 , later only:

  • the move constructor auto-generated if there no user-declared copy constructor, copy assignment operator or destructor, , if generated move constructor valid (e.g. if wouldn't need assign constant members) (§12.8/10).
  • the move assignment operator auto-generated if there no user-declared copy constructor, copy assignment operator or destructor, , if generated move assignment operator valid (e.g. if wouldn't need assign constant members) (§12.8/21).

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -