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 ).