Boost logo

Boost Users :

Subject: Re: [Boost-users] shared_from_this - derived classes (yes, I googled)
From: Igor R (boost.lists_at_[hidden])
Date: 2011-10-01 14:17:00


> I inherited from enable_shared_from_this in my base class.
> When I called shared_from_this() in my derived class it throws an exception.
> When I go up the call stack I see that in the boost implementation weak_ptr is
> NULL and count is NULL.
>
> I ensured the derived class was instatiated as a shared_ptr by using a fatory method.

If you create shared_ptr, as you described, and then call
shared_from_this(), it should not throw exceptions. If it does, can
you provide a trivial reproducing sample?


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