xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/hicpp/undelegated-constructor.rst (revision c6fa07ca966eb8902465adbe2c6c1e41a108881c)
1.. title:: clang-tidy - hicpp-undelegated-constructor
2.. meta::
3   :http-equiv=refresh: 5;URL=../bugprone/undelegated-constructor.html
4
5hicpp-undelegated-constructor
6=============================
7
8This check is an alias for :doc:`bugprone-undelegated-constructor <../bugprone/undelegated-constructor>`.
9Partially implements `rule 12.4.5 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-standard/special-member-functions>`_
10to find misplaced constructor calls inside a constructor.
11
12.. code-block:: c++
13
14  struct Ctor {
15    Ctor();
16    Ctor(int);
17    Ctor(int, int);
18    Ctor(Ctor *i) {
19      // All Ctor() calls result in a temporary object
20      Ctor(); // did you intend to call a delegated constructor?
21      Ctor(0); // did you intend to call a delegated constructor?
22      Ctor(1, 2); // did you intend to call a delegated constructor?
23      foo();
24    }
25  };
26