Resource management
R.32
Take a `unique_ptr<widget>` parameter to express that a function assumes ownership of a `widget`
Reason
Using unique_ptr in this way both documents and enforces the function call's ownership transfer.
Example
void sink(unique_ptr<widget>); // takes ownership of the widget
void uses(widget*); // just uses the widget
Enforcement
- (Simple) Warn if a function takes a
Unique_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.