by jstarks · 10y ago · 0 comments
Your point is still valid, though -- a shared_ptr should be copied only when you actually want to increase the reference count.
In general, I try to avoid shared_ptr unless I really need reference counting. unique_ptr is much easier to reason about and is much more efficient.
Some might argue that using shared pointers is better for this application, but then you must also deal with potential reference cycles and add weak pointers to the mix eventually, and in addition to these concerns, handle any runtime hits for the reference counting.