| 1 |
.. title:: clang-tidy - hicpp-undelegated-constructor |
| 2 |
.. meta:: |
| 3 |
:http-equiv=refresh: 5;URL=../bugprone/undelegated-constructor.html |
| 4 |
|
| 5 |
hicpp-undelegated-constructor |
| 6 |
============================= |
| 7 |
|
| 8 |
This check is an alias for `bugprone-undelegated-constructor <../bugprone/undelegated-constructor.html>`_. |
| 9 |
Partially implements `rule 12.4.5 <http://www.codingstandard.com/rule/12-4-5-use-delegating-constructors-to-reduce-code-duplication/>`_ |
| 10 |
to 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 |
}; |