Open
Description
std::shared_ptr
's constructor has a lot of overloads, one of them has unique_ptr
parameter.
People don't know about existense of that overload.
I've seen the code like this all over the place:
std::shared_ptr<Foo> process(std::unique_ptr<Foo> foo) {
// ...
return std::shared_ptr<Foo>(foo.release());
}
Need a check that will find such patterns and will change it to use constructor's overload with unique_ptr
parameter:
std::shared_ptr<Foo> process(std::unique_ptr<Foo> foo) {
// ...
return std::shared_ptr<Foo>(std::move(foo));
}