Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-06-18 05:43:06


From: "Peter" <piotrus_at_[hidden]>
> Is it possible to pass a pointer of a class member function into a thread
??
> I have no problems passing functions (or pointers to functions rather)
which
> are not members of any classes. However when I try to pass member
functions,
> I get compile errors. I am using MSVS 6.0 on win 2000.

[...]

> boost::thread myThread(&object1.fun1) ; // PROBLEM HERE

This is not a pointer to a member function; you are trying to combine an
object with a member function (a construct known as "closure.")

Standard C++ doesn't have closures, but you can use
boost::bind(&testClass1::fun1, &object1) to simulate one.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk