Always pass your shared_ptr by const reference:
void f(const shared_ptr<Dataset const>& pds) {...}
void g(const shared_ptr<Dataset const>& pds) {...}
Edit: Regarding the safety issues mentioned by others:
- When using
shared_ptrheavily throughout an application, passing by value will take up a tremendous amount of time (I’ve seen it go 50+%). - Use
const T&instead ofconst shared_ptr<T const>&when the argument shall not be null. - Using
const shared_ptr<T const>&is safer thanconst T*when performance is an issue.