# Extra Clang Tools 21.1.8 documentation

## clang-tidy - cppcoreguidelines-special-member-functions

# cppcoreguidelines-special-member-functions

The check finds classes where some but not all of the special member functions are defined.

By default the compiler defines a copy constructor, copy assignment operator, move constructor, move assignment operator and destructor. The default can be suppressed by explicit user-definitions. The relationship between which functions will be suppressed by definitions of other functions is complicated and it is advised that all five are defaulted or explicitly defined.

Note that defining a function with `= delete` is considered to be a definition.

This check implements C.21 from the C++ Core Guidelines.

## Options

AllowSoleDefaultDtor

  When set to true (default is false), this check will only trigger on destructors if they are defined and not defaulted.

      struct A { // This is fine.
        virtual ~A() = default;
      };

      struct B { // This is not fine.
        ~B() {}
      };

      struct C {
        // This is not checked, because the destructor might be defaulted in
        // another translation unit.
        ~C();
      };

AllowMissingMoveFunctions

  When set to true (default is false), this check doesn’t flag classes which define no move operations at all. It still flags classes which define only one of either move constructor or move assignment operator. With this option enabled, the following class won’t be flagged:

      struct A {
        A(const A&);
        A& operator=(const A&);
        ~A();
      };

AllowMissingMoveFunctionsWhenCopyIsDeleted

  When set to true (default is false), this check doesn’t flag classes which define deleted copy operations but don’t define move operations. This flag is related to Google C++ Style Guide Copyable and Movable Types. With this option enabled, the following class won’t be flagged:

      struct A {
        A(const A&) = delete;
        A& operator=(const A&) = delete;
        ~A();
      };

AllowImplicitlyDeletedCopyOrMove

  When set to true (default is false), this check doesn’t flag classes which implicitly delete copy or move operations. With this option enabled, the following class won’t be flagged:

      struct A : boost::noncopyable {
        ~A() { std::cout << "dtor\n"; }
      };

IgnoreMacros

  If set to true, the check will not give warnings for classes defined inside macros. Default is true.