summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs/clang-tidy/checks/modernize-use-default.rst
blob: 157a337c97beddefe5ebcc3c35f0e5cde8846083 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.. title:: clang-tidy - modernize-use-default

modernize-use-default
=====================

This check replaces default bodies of special member functions with ``=
default;``.  The explicitly defaulted function declarations enable more
opportunities in optimization, because the compiler might treat explicitly
defaulted functions as trivial.

.. code-block:: c++

  struct A {
    A() {}
    ~A();
  };
  A::~A() {}

  // becomes

  struct A {
    A() = default;
    ~A();
  };
  A::~A() = default;

.. note::
  Copy-constructor, copy-assignment operator, move-constructor and
  move-assignment operator are not supported yet.
OpenPOWER on IntegriCloud