C++11 - Compiler Generated Member Functions

The compiler generates the following 6 member functions for a class -
1. Default Ctor
2. Default Dtor
3. Copy Ctor
4. Copy Assignment Operator
5. Move Ctor
6. Move Assignment Operator

These constraints apply to their generation -
1. They are generated only if they have not been declared and are required by the code.
2. They are public, inline and non-virtual (except for dtor, see #3).
3. The default dtor is virtual if the class derives from a base calss which contains a virtual dtor. It is also declared noexcept.
4. The default ctor is generated only if no other ctor is declared.
5. The move ctor and move assignment operator perform memberwise moves of non-static data members and base class members. If these members can’t be moved then the appropriate copy operation is performed.
6. The copy ctor and copy assignment operator are generated independent of each other i.e. if they are declared they are generated.
7. The move functions are not independent. If either of them is declared the other is not default generated.
8. The move functions are not generated if any of the copy functions is declared. Similarly copy functions are not generated if any of the move functions is declared.
9. The move functions are not generated if there is user declared dtor. This should also apply to copy functions, however this isn’t yet implemented to maintain backward compatibility with C++98.

Rule of 3 - to better manage the resources of a class, if you declared one of these then declare all three -
1. destructor
2. copy assignment operator
3. copy constructor