The cost of passing by shared_ptr
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_ptr heavily throughout an application, passing by value will take up a tremendous amount of time (I’ve seen it go 50+%). Use const T& instead of … Read more