
12 Sep
2011
12 Sep
'11
5:41 p.m.
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);