17 Jul
2006
17 Jul
'06
7:16 p.m.
I'm trying to pass a member function as the callback in boost::thread. Given this:
class my_class { ... void foo(void); ... };
Instincts told me to do this:
boost::thread my_thread( std::mem_fun(&my_class::foo) );
You want to use boost::bind for this. The below should work. my_class *myClassPtr = new my_class; boost::thread my_thread( boost::bind(&my_class::foo, myClassPtr) );