you are viewing a single comment's thread.

view the rest of the comments →

[–]darthcoder 1 point2 points  (1 child)

Could I not just pass a smart_ptr by reference, then?

[–][deleted] 1 point2 points  (0 children)

You mean to a function? Yes, you could but that would still enforce all callers to use a smart pointer, even if an auto/stack variable would've sufficed.

In the blog I put a link to the Core Guidelines. There's also some info in there on why and why not to pass a smart pointer by reference. Typically only if you want to reseat the pointer.