"If you define or delete any default operation in the type, define or delete them all."
C++ Core Guidelines: C.21: If you define or =delete any default operation, define or =delete them all
Special operations like constructors are assumed to alter behavior of types so that they rely more on language mechanisms to automatically enforce specific scenarios (the canonical example is resource management). If any of these operations is explicitly defined, defaulted or deleted (as an indication that user wants to avoid any special handling of a type) it would be inconsistent to leave the other operations from the same group unspecified (i.e. implicitly defined by compiler).
- This check implements "the rule of five" which treats the following operations as special:
- copy constructors;
- move constructors;
- copy assignment operators;
- move assignment operators;
- The rule doesn’t check if operations are defined in the same way, i.e. it is okay to mix deleted and defaulted operations with explicitly defined, but they all must be specified somehow if any of them appears.
- Access levels are not important and can also be mixed.
- The warning flags the first non-static function definition of a type, once per type.