1.. title:: clang-tidy - cppcoreguidelines-special-member-functions 2 3cppcoreguidelines-special-member-functions 4========================================== 5 6The check finds classes where some but not all of the special member functions 7are defined. 8 9By default the compiler defines a copy constructor, copy assignment operator, 10move constructor, move assignment operator and destructor. The default can be 11suppressed by explicit user-definitions. The relationship between which 12functions will be suppressed by definitions of other functions is complicated 13and it is advised that all five are defaulted or explicitly defined. 14 15Note that defining a function with ``= delete`` is considered to be a 16definition. 17 18This rule is part of the "Constructors, assignments, and destructors" profile of the C++ Core 19Guidelines, corresponding to rule C.21. See 20 21https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all. 22 23Options 24------- 25 26.. option:: AllowSoleDefaultDtor 27 28 When set to `1` (default is `0`), this check doesn't flag classes with a sole, explicitly 29 defaulted destructor. An example for such a class is: 30 31 .. code-block:: c++ 32 33 struct A { 34 virtual ~A() = default; 35 }; 36 37.. option:: AllowMissingMoveFunctions 38 39 When set to `1` (default is `0`), this check doesn't flag classes which define no move 40 operations at all. It still flags classes which define only one of either 41 move constructor or move assignment operator. With this option enabled, the following class won't be flagged: 42 43 .. code-block:: c++ 44 45 struct A { 46 A(const A&); 47 A& operator=(const A&); 48 ~A(); 49 }; 50 51.. option:: AllowMissingMoveFunctionsWhenCopyIsDeleted 52 53 When set to `1` (default is `0`), this check doesn't flag classes which define deleted copy 54 operations but don't define move operations. This flags is related to Google C++ Style Guide 55 https://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types. With this option enabled, the 56 following class won't be flagged: 57 58 .. code-block:: c++ 59 60 struct A { 61 A(const A&) = delete; 62 A& operator=(const A&) = delete; 63 ~A(); 64 }; 65