Boost logo

Boost Users :

Subject: Re: [Boost-users] [SmartPtr] enable_shared_from_raw / weak_from_raw remains not associated
From: Frank Mori Hess (fmh6jj_at_[hidden])
Date: 2013-05-20 11:02:06


On Fri, May 17, 2013 at 3:22 AM, Slava
<Viatcheslav.Sysoltsev_at_[hidden]> wrote:
> boost::shared_from_raw(this); // necessary for weak_from_raw() to
> function properly
> this->child->parent = boost::weak_from_raw(this);

> I reached what I needed, but I have some bad feeling about how it works. It
> does not look sane, boost::shared_from_raw(this) class is there only to
> produce the desired side effect.

You could just not use weak_from_raw at all. You can initialize your
weak_ptr from the shared_ptr returned by shared_from_raw.

--
Frank

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