|
Boost Users : |
Subject: Re: [Boost-users] "weak" binding to member?
From: Igor R (boost.lists_at_[hidden])
Date: 2011-09-12 13:41:38
> I don't know what you mean by that.
I mean that you can pass a weak_ptr along with the binder:
void setYourFunctor(const function<void(void)> &func, const
weak_ptr<void> &track)
{
// store "func" and "track"
func_ = func;
track_ = track;
}
// Now in the place where "func_" should be called:
void call()
{
shared_ptr<void> p = track_.lock();
if (p)
func_();
}
// Now use it this way:
shared_ptr<YourClass> ptr = ...;
setYourFunctor(bind(&YourClass::doSomething, ptr.get()), ptr);
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