Boost logo

Boost Users :

Subject: Re: [Boost-users] weak_ptr::lock is not thread safe
From: Cliff Green (cliffg_at_[hidden])
Date: 2010-12-16 11:28:17


From: Dmytro Ovdiienko:
>class SomeClass{
>public:
> boost::shared_ptr<SomeClass> s_this_;
> boost::weak_ptr<SomeClass> w_this_;
>
> SomeClass()
> {
> s_this_.reset( this );
> w_this_ = s_this_;
    
Shouldn't you be using shared_from_this()? Creating a shared_ptr from "this" doesn't work otherwise. Check out the shared_ptr docs for more info.

Cliff



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