Boost logo

Boost Users :

Subject: Re: [Boost-users] enable_shared_from_this()
From: Igor R (boost.lists_at_[hidden])
Date: 2013-02-04 12:46:49


> Can someone please explain why this code:
>
> struct Foo : boost::enable_shared_from_this<Foo> {};
> Foo* p_foo = new Foo;
> boost::shared_ptr<Foo> ptr_foo(p_foo->shared_from_this());
>
> is throwing?

The documentation explains:
http://www.boost.org/doc/libs/1_52_0/libs/smart_ptr/enable_shared_from_this.html
<<Requires: enable_shared_from_this<T> must be an accessible base
class of T. *this must be a subobject of an instance t of type T .
There must exist at least one shared_ptr instance p that owns t.>>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net