Passing Smart Pointers Reference Sheet
The following is based on CppCon 2014: Herb Sutter “Back to the Basics! Essentials of Modern C++ Style”
unique_ptr<Widget> factory() // source: produces Widgetvoid sink(unique_ptr<Widget>) // sink - consumes widget, takes ownershipvoid reseat(unique_ptr<Widget>&) // "will" or "might" reseat ptr (replace Widget)void thinko(const unique_ptr<Widget>&) // Use const& instead\
shared_ptr<Widget> factory() // source + shared ownershipvoid share(shared_ptr<Widget>) // share - "will" retain refcountvoid reseat(shared_ptr<Widget>&) // "Will" or "might" reseat ptrvoid may_share(const shared_ptr<Widget>&) // "Might" retain refcount
unique_ptr<Widget>& get_intance() // Weird and no reason. A singleton can be a regular reference.See also: