readability-redundant-member-init.rst 1.2 KB

readability-redundant-member-init

Finds member initializations that are unnecessary because the same default constructor would be called if they were not present.

Example

// Explicitly initializing the member s is unnecessary.
class Foo {
public:
  Foo() : s() {}

private:
  std::string s;
};

Options

// Explicitly initializing member s and base class Bar is unnecessary.
struct Foo : public Bar {
  // Remove s() below. If IgnoreBaseInCopyConstructors!=0, keep Bar().
  Foo(const Foo& foo) : Bar(), s() {}
  std::string s;
};