Boost logo

Boost Users :

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



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net