AutosarC++18_10-A8.4.13

A std::shared_ptr shall be passed to a function as: (1) a copy to express the function shares ownership (2) an lvalue reference to express that the function replaces the managed object (3) a const lvalue reference to express that the function retains a reference count

Required inputs: IR

A std::shared_ptr shall be passed to a function as:
  1. a copy to express the function shares ownership
  2. an lvalue reference to express that the function replaces the managed object
  3. a const lvalue reference to express that the function retains a reference count.
A std::unique_ptr shall be passed to a function as:
  1. a copy to express the function assumes ownership
  2. an lvalue reference to express that the function replaces the managed object.

Possible Messages

Key

Text

Severity

Disabled

const_lvalue

std::shared_ptr passed as const lvalue reference but function does not copy it

None

False

lvalue

{} passed as lvalue reference but function does not replace object

None

False

shared_ptr_rvalue

std::shared_ptr passed as rvalue reference

None

False

unique_ptr_rvalue

std::unique_ptr passed as rvalue reference but function does not move object

None

False

Options

consider_shared_ptrs

consider_shared_ptrs : bool = True

Whether std::shared_ptrs should be considered
 

consider_unique_ptrs

consider_unique_ptrs : bool = False

Whether std::unique_ptrs should be considered