Purpose of const boost::shared_ptr<T>& as function argument?

boost, c++

Solution

Passing this by value is going to copy it which results in a reference count increment, synchronized across all threads. Definitely non-negligible.

Problem

I'm using a certain large and well-maintained open-source C++ library and came across a class definition having a constructor of the form ``` class SomeClass { SomeClass( const boost::shared_ptr<SomeOtherClass>& ); } ``` My question is: what's the point of passing a `const boost::shared_ptr<T>` by reference? Is there really a non-negligible amount of overhead associated with passing a `boost::shared_ptr<T>` by value, or is there some other kind of danger to passing a `boost::shared_ptr<T>` by value that I'm not aware of?

Original source