
I have problems with the attached code (test.cpp, extracted from the original class only with the relevant code). The member template constructor of CCycleThread takes an argument and passes this to boost bind. The binding is to a another member template method which is the thread function for boost thread:
boost::thread(boost::bind(&CCycleThread::execute<T>,this,t)
The template parameter type is deduced by the argument type passed by the user.
If the type is an ordinary function the code works fine. If the argument itself is another boost bind object the compilation fails!
, this, boost::protect(t)))); However, the problem is that now if a user passes a simple function
If the argument is a binder, you should wrap it with boost::protect
and specialize CCycleThread::execute accordingly:
m_thread.reset(new
boost::thread(boost::bind(&CCycleThread::execute