
Edward Diener wrote:
class Publisher { typedef boost::function<void> Function; public: void SetChecker(const Function& Callback){ } void Publish(){} };
class Manager { public: Manager(); private: void Check() {} };
Manager::Manager() { Publisher d; d.SetChecker(std::mem_fun(&Manager::Check));
try: d.SetChecker(boost::bind(&Manager::Check,this));
Brilliant - thanks! Would you mind giving me a short rationale about this, since I am a newbie regarding function pointers and function (object?) adaptors. SO, if using an stl algorithm like vector<Publisher> p; for_each(p.begin(), p.end(), mem_fun(&Publisher::Publish)); I don't have to bind anything, do I? mem_fun() returns a mem_fun_t functor object, which will receive the Publisher object pointer through each intern for_each call? And that object pointer passing was missing in my code and was achieved in your code through the binding? I had already looked at boost::bind but still cannot figure out its interface template<class F, class A1> unspecified-3-1 bind(F f, A1 a1); What is this returning? Thanks again Ali