Passing std:: or boost::shared_ptr as a reference to a function

This is a discussion on Passing std:: or boost::shared_ptr as a reference to a function within the C++ Programming forums, part of the General Programming Boards category; I was suggested to replace in few places passing const shared_ptr by value to passing by reference (e.g. change const ...

Passing std:: or boost::shared_ptr as a reference to a function

I was suggested to replace in few places passing const shared_ptr by value to passing by reference (e.g. change const std::shared_ptr param to const std::shared_ptr& param) when I was checking my project with PVS-Studio, the static code analysis tool.

I understand that for performance hot-spots it might be a good optimization as creating a temporary copy of shared_ptr requires updating reference counter which is a interlocked operation.

So the question is - how safe is this optimization? Are there any cases when it could not be used?

I can't for the life of me understand why you would start a new thread in a different online community for a question that was already answered for you. Were the answers that you were given not up to standard? Even so, you should have asked for clarification, and only seek help elsewhere after it becomes clear that you are simply making no progress getting a good answer in that online community.

I can't for the life of me understand why you would start a new thread in a different online community for a question that was already answered for you. Were the answers that you were given not up to standard? Even so, you should have asked for clarification, and only seek help elsewhere after it becomes clear that you are simply making no progress getting a good answer in that online community.

These communities are different, and I'm trying to get ideas and thoughts from as many people as possible.
As I see there is no single opinion yet on this subject, I'd like to get to the bottom of the problem to be able then to start preaching proper solution.

Also the link you have mentioned is a discussion, there is no final answer (hopefully - yet)