Since C++11 you should take it by value over const& more often than you might think.
If you are taking the std::shared_ptr (rather than the underlying type T), then you are doing so because you want to do something with it.
If you would like to copy it somewhere, it makes more sense to take it by copy, and std::move it internally, rather than taking it by const& and then later copying it. This is because you allow the caller the option to in turn std::move the shared_ptr when calling your function, thus saving yourself a set of increment and decrement operations. Or not. That is, the caller of the function can decide whether or not he needs the std::shared_ptr around after calling the function, and depending on whether or not move or not. This is not achievable if you pass by const&, and thus it is then preferably to take it by value.
Of course, if the caller both needs his shared_ptr around for longer (thus can not std::move it) and you don't want to create a plain copy in the function (say you want a weak pointer, or you only sometimes want to copy it, depending on some condition), then a const& might still be preferable.
For example, you should do
void enqueue(std::shared<T> t) m_internal_queue.enqueue(std::move(t));
over
void enqueue(std::shared<T> const& t) m_internal_queue.enqueue(t);
Because in this case you always create a copy internally
shared_ptr
, and I can change it if I want.", while the value version says "I'm going to copy yourshared_ptr
, so while I can change it you'll never know.) A const-reference parameter is the real solution, which says "I'm going to alias someshared_ptr
, and I promise not to change it." (Which is extremely similar to by-value semantics!)shared_ptr
class member. Do you do it by const-refs?weak_ptr
to a shared_ptr.