1.. title:: clang-tidy - modernize-use-equals-delete 2 3modernize-use-equals-delete 4=========================== 5 6Identifies unimplemented private special member functions, and recommends using 7``= delete`` for them. Additionally, it recommends relocating any deleted 8member function from the ``private`` to the ``public`` section. 9 10Before the introduction of C++11, the primary method to effectively "erase" a 11particular function involved declaring it as ``private`` without providing a 12definition. This approach would result in either a compiler error (when 13attempting to call a private function) or a linker error (due to an undefined 14reference). 15 16However, subsequent to the advent of C++11, a more conventional approach emerged 17for achieving this purpose. It involves flagging functions as ``= delete`` and 18keeping them in the ``public`` section of the class. 19 20To prevent false positives, this check is only active within a translation 21unit where all other member functions have been implemented. The check will 22generate partial fixes by introducing ``= delete``, but the user is responsible 23for manually relocating functions to the ``public`` section. 24 25.. code-block:: c++ 26 27 // Example: bad 28 class A { 29 private: 30 A(const A&); 31 A& operator=(const A&); 32 }; 33 34 // Example: good 35 class A { 36 public: 37 A(const A&) = delete; 38 A& operator=(const A&) = delete; 39 }; 40 41 42.. option:: IgnoreMacros 43 44 If this option is set to `true` (default is `true`), the check will not warn 45 about functions declared inside macros. 46