|
Boost Users : |
Subject: Re: [Boost-users] Problem with weak_ptr exception
From: Nigel Rantor (wiggly_at_[hidden])
Date: 2009-10-28 10:39:33
Jacob Carlborg wrote:
> On 10/28/09 15:56, Stefan Strasser wrote:
>> I can't make sense of your code ("weakThis" in both A and B, even
>> though B is
>> derived from A?), but have a look at boost::shared_from_this
>
> If I don't have a weak_ptr in B I get this error when trying to create a
> shared_ptr<B> from a weak_ptr<A>:
> /shared_ptr.hpp:207: error: invalid conversion from 'A* const' to 'B*'
The compiler is stopping you from doing something unsafe.
> I've already tried boost::shared_from_this and it gives me the same result.
I think it would be useful to show what you're actually trying to
achieve becasue you can probably do it with shared_from_this(), and if
you can't then it looks like it's because of casting issues rather than
the shared_from_this code...
n
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