Boost logo

Boost Users :

From: Steven Wooding (steve.apo_at_[hidden])
Date: 2006-02-14 16:34:59


Hi,

I've had a good search on the mailing list and while some posts have
got close to my problem and given me a few glues, my code does't quite
work the way I want it to.

My goal is to have a (non-static) class member function run in a child
thread + passing a parameter to it. The code I've got at the moment
goes something like this:

void MyClass::spawn_threads()
{
  for ( int ii = 0; ii < num_threads; ++ii)
  {
     threadGroup.create_thread( boost::bind( ChildThreadFunc, _1, ii));
  }
}

void MyClass::ChildThreadFunc( int &threadNumber)
{
  // Does some work
}

I get the following error on the create_thread line:

error: no matching function call to bind(<unknown type>, boost::arg<1>&, int&)
cadiates are: .... boost:bind(F, A1, A2)[ with F= void
(MyClass::*)(int&), A1=boost:arg<1>, A2=int]

I'm confused by the <unknown type> business. How do I tell it the correct type?

Maybe someone could point out where I've erred.

Cheers,

Steve.


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