|
Boost Users : |
Subject: Re: [Boost-users] shared_from_this - derived classes (yes, I googled)
From: Christopher Pisz (cpisz_at_[hidden])
Date: 2011-10-01 14:07:01
Igor R <boost.lists <at> gmail.com> writes:
>
> <...>
> > I read on google that you can only use shared_from_this on ONE class type
in a
> > class hierarchy. I did not understand the details of why.
>
> You probably mean that you should inherit enable_shared_from_this only once.
> But then you can use shared_from_this wherever you wish.
>
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.
I don't know what else to do.
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