Qt-RuleOfTwoSoft

A trivial copy constructor or copy assignment operator is called despite non-trivial counter parts

Required inputs: IR

Finds places where:
  1. You are calling a trivial copy constructor of a class which has a non-trivial copy assignment operator
  2. You are calling a trivial copy assignment operator of a class which has a non-trivial copy constructor
It will not warn on classes that violate the rule of two unless you actually use the copy constructor or the copy assignment operator, otherwise it would generate lots of warnings. If you are really interested in all warnings, see the rule-of-three check instead of this rule-of-two-soft.

Beware that removing copy constructors or copy assignment operators might make the class trivially copyable, which is not ABI compatible.

This rule is based on clazy rule rule-of-two-soft

Possible Messages

Key

Text

Severity

Disabled

using_assignment_operator

Using trivial copy assignment operator but class {} has non-trivial copy constructor.

None

False

using_copy_constructor

Using trivial copy constructor but class {} has non-trivial copy assignment operator.

None

False

Options

collect_usages

collect_usages : bool = False

Report multiple usages only once at the class.
 

level

level : int = 1

Importance level of the rule as given for clazy. 0 is most desirable, higher values fall off in quality.