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?
Any thoughts on this would be appreciated.