
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!
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<boost::_bi::protected_bind_t<T>
, this, boost::protect(t)))); However, the problem is that now if a user passes a simple function pointer, it wont compile. Thus, you should separate the 2 cases using enable_if/disable_if, but I can't realise right now what type trait could be useful for this purpose...