Boost logo

Boost Users :

Subject: Re: [Boost-users] [shared_ptr] Member functions as deallocators
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-06-03 10:02:22


AMDG

Michael Crawford wrote:
> I'm using shared_ptr to hold a SceneManager object. In this particular
> case, I don't actually want the shared_ptr to have ownership of the
> SceneManager, but rather take advantage of it to insure that the
> SceneManager it holds is cleared when the containing object (a game's state)
> is destroyed. The deallocator needs to call SceneManager::clearScene, but
> it needs to call it on the held object, so the deallocator call would be
> essentially
> (pointer held in shared_ptr)->clearScene( );
> Can anyone give me some guidance on how to accomplish this

The pointer will be passed as an argument to the deallocator.

boost::shared_ptr<SceneManager> p(s,
boost::bind(&SceneManager::clearScene, _1));

In Christ,
Steven Watanabe


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