55 lines · plain
1.. title:: clang-tidy - modernize-use-default-member-init2 3modernize-use-default-member-init4=================================5 6This check converts constructors' member initializers into the new7default member initializers in C++11. Other member initializers that match the8default member initializer are removed. This can reduce repeated code or allow9use of '= default'.10 11.. code-block:: c++12 13 struct A {14 A() : i(5), j(10.0) {}15 A(int i) : i(i), j(10.0) {}16 int i;17 double j;18 };19 20 // becomes21 22 struct A {23 A() {}24 A(int i) : i(i) {}25 int i{5};26 double j{10.0};27 };28 29.. note::30 Only converts member initializers for built-in types, enums, and pointers.31 The `readability-redundant-member-init` check will remove redundant member32 initializers for classes.33 34Options35-------36 37.. option:: UseAssignment38 39 If this option is set to `true` (default is `false`), the check will initialize40 members with an assignment. For example:41 42.. code-block:: c++43 44 struct A {45 A() {}46 A(int i) : i(i) {}47 int i = 5;48 double j = 10.0;49 };50 51.. option:: IgnoreMacros52 53 If this option is set to `true` (default is `true`), the check will not warn54 about members declared inside macros.55