AutosarC++18_03-A20.8.5

std::make_unique shall be used to construct objects owned by std::unique_ptr

Required inputs: IR

Possible Messages

Key

Text

Severity

Disabled

shared_ctor_used

Call to constructor of std::shared_ptr rather than using std::make_shared.

None

False

unique_ctor_used

Call to constructor of std::unique_ptr rather than using std::make_unique.

None

False

Options

consider_std_shared

consider_std_shared : bool = False

Whether calls to the constructor of std::shared_ptr should be reported.
 

consider_std_unique

consider_std_unique : bool = True

Whether calls to the constructor of std::unique_ptr should be reported.
 

only_suggest_semantically_identical_replacements

only_suggest_semantically_identical_replacements : bool = True

Only suggest replacing constructor calls by make_shared or make_unique if the replacement would be semantically equivalent. For instance, std::shared_ptr{new B} is equivalent to std::make_shared(), but std::shared_ptr{b} is not equivalent to either std::make_shared() or std::make_shared(b).