From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-21 19:06:20
From: "David Abrahams" <dave_at_[hidden]>
> All the examples I've been able to come up with where I want a weak_ptr
> also lead naturally to wanting shared_from_this()... well, actually,
> weak_from_this(). The basic paradigm is that a member function is used to
> add owned objects which need a back-pointer. Inside a member function you
> have a raw pointer, not a shared_ptr, regrettably.
> Is there an example which maps naturally onto non-intrusive use of
std::vector< shared_ptr<GameObject> > objects;
class Tank: public GameObject
virtual void update()
if(shared_ptr<GameObject> p = make_shared(target_))
target_ = this->acquireNewTarget(objects);
The basic paradigm would be siblings that refer to each other.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk