From: Matt Amato (matt.amato_at_[hidden])
Date: 2006-07-17 15:16:06


>
> 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) );