[Solved] What is the advantage of passing by reference to shared_ptr over passing by reference directly

The only reason a function should accept a std::shared_ptr as a argument is if it may need to share or modify the ownership of the resource. If not, don’t pass a std::shared_ptr. If the function will definitely need to take shared ownership then it should accept a std::shared_ptr by value. Only accept a std::shared_ptr& if … Read more