
4 Feb
2013
4 Feb
'13
10:46 a.m.
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.... <<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.>>