Resource management
R.36
Take a `const shared_ptr<widget>&` parameter to express that it might retain a reference count to the object
Reason
This makes the function's ??? explicit.
Example, good
void share(shared_ptr<widget>); // share -- "will" retain refcount
void reseat(shared_ptr<widget>&); // "might" reseat ptr
void may_share(const shared_ptr<widget>&); // "might" retain refcount
Enforcement
- (Simple) Warn if a function takes a
Shared_pointer<T>parameter by lvalue reference and does not either assign to it or callreset()on it on at least one code path. Suggest taking aT*orT&instead. - (Simple) ((Foundation)) Warn if a function takes a
Shared_pointer<T>by value or by reference toconstand does not copy or move it to anotherShared_pointeron at least one code path. Suggest taking aT*orT&instead. - (Simple) ((Foundation)) Warn if a function takes a
Shared_pointer<T>by rvalue reference. Suggesting taking it by value instead.