xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/modernize/use-equals-default.rst (revision eb87e55c9aade5d7b42606487e69b5f3a6da1e65)
1.. title:: clang-tidy - modernize-use-equals-default
2
3modernize-use-equals-default
4============================
5
6This check replaces default bodies of special member functions with ``=
7default;``. The explicitly defaulted function declarations enable more
8opportunities in optimization, because the compiler might treat explicitly
9defaulted functions as trivial.
10
11.. code-block:: c++
12
13  struct A {
14    A() {}
15    ~A();
16  };
17  A::~A() {}
18
19  // becomes
20
21  struct A {
22    A() = default;
23    ~A();
24  };
25  A::~A() = default;
26
27.. note::
28  Move-constructor and move-assignment operator are not supported yet.
29
30Options
31-------
32
33.. option:: IgnoreMacros
34
35   If set to `true`, the check will not give warnings inside macros and will
36   ignore special members with bodies contain macros or preprocessor directives.
37   Default is `true`.
38