Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is definitely better to use T& instead of shared_ptr<T>&. Passing references to either unique or shared pointers is just adding a layer of indirection you are never going to use, unless you intend to copy-construct the pointer object later, which sounds more like you need to rethink your object design if you want to do something that messy.


To be clear, I was not referring to references at all but rather to naked pointers you get by calling get() on a unique_ptr, and passing those to non-owning classes/functions that need them (including third-party APIs).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: