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?
Since Foo embeds a weak_ptr, why can't it new the pi_ on the spot?
(I'm using Boost 1.44).
PS: On a related note, why doesn't boost::shared_ptr<Foo>(p_foo)I suspect something like this could be made to work if the previous also worked -- but the class is documented to *not* allow the previous to work. I'd have to think about why (or maybe Peter will enlighten us).
(where p_foo is a raw Foo*) implicitly apply the aliasing Ctor, to
share the same px, to avoid the classic bug of having several
different pn on the same px, since p_foo derives from
enable_shared_from_this()? Initially i thought that's what
sp_enable_shared_from_this() and pe->_internal_accept_owner() were
meant to do, but obviously that's not the case.