Boost logo

Boost Users :

Subject: [Boost-users] [boost-users][bind, lambda, ...] binding unused actual parameter
From: Igor R (boost.lists_at_[hidden])
Date: 2009-04-16 07:21:02


Hello,

Is it possible somehow to make a binder that stores "unexpected" argument?

Motivation: I have to create & pass a callback handler from within
intusively ref-counted object (MS-ATL) to an outer asynchronous
subsystem. If the object were shared-ptr enabled, I'd do this as
usually:

ThisObj::handler()
{
  //...
}
ThisObj::doSomething()
{
  asyncSubsystem_->doSomething(&ThisObj::handler, shared_from_this());
}

However, in my case I have to do something like this:

asyncSubsystem_->doSomething(&ThisObj::handler, this, mySmartPtr); //
store someOtherSmartPtr in the functor, just to ensure "this" won't
die before the handler is invoked

Is it possible with bind, lambda or some other library?

Thanks.


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