On 29/01/2016 14:35, Emil Dotchevski wrote:
On Thu, Jan 28, 2016 at 12:20 PM, Noah
wrote: registered_ptr can point to stack allocated objects (just like native C++ pointers can),
shared_ptr can point to stack-allocated objects, too. As a benefit, if you use shared_ptr to point at a stack-allocated object, you also get the weak_ptr functionality.
Yes, you can make a shared_ptr that points at a stack object (by using a null deleter) but AFAIK this doesn't actually work as expected unless you can guarantee that no shared_ptr instances will survive destruction of the stack frame (ie. it is only used within the call chain and never copied outside of it). And it's way too easy to break that guarantee because it's not the semantics that shared_ptr was designed for.