[bind] how to get a funtor of a function since the function's template argument is a functor
// how to get the functor of function caller below,which could be used in a boost::thread or other condition #include <boost/bind.hpp> #include <iostream> class BufferMoniter { public: void maitain() { std::cout <<" BufferMoniter" << std::endl; } }; class LocalPeer { public: template <class T> void caller(unsigned int interval,T t) { //do something t(); } void fork() { BufferMoniter *pBuffer=new BufferMoniter( ); caller(500,boost::bind(&BufferMoniter::maitain,pBuffer)); //I want a functor of it //boost::thread thrd( ); //insert here //thre.join(); } }; //best wishes
On Thursday 01 February 2007 23:02 pm, hongleij@126.com wrote:
caller(500,boost::bind(&BufferMoniter::maitain,pBuffer)); //I want a functor of it
Could you do something like boost::function<void ()> myfunc = boost::bind(&BufferMoniter::maitain,pBuffer); caller(500, myfunc); ? -- Frank
participants (2)
-
Frank Mori Hess
-
hongleij@126.com