|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-12-02 08:23:49
Travis Parks wrote:
> Hello:
> I just started using some boost today. I am trying to use a non-static
> member function as the deleter in a shared_ptr. I was looking at the
> source code and I don't think it is supported. This is what I had:
>
>
> shared_ptr<Environment> environment(Environment::createEnvironment(),
> Environment::terminateEnvironment);
> string userName = "monkey_bottoms";
> string password = "blahblahblah"
> shared_ptr<Connection> connection(
> environment->createConnection(
> userName,
> password),
> &Environment::terminateConnection);
>
> This didn't work at all!
Use boost::bind( &Environment::terminateConnection, environment, _1 ) as a
deleter.
If for some reason you don't want connections to keep a shared_ptr to the
environment and prevent its deletion, you can use boost::bind(
&Environment::terminateConnection, environment.get(), _1 ).
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