I’m trying to have a class that when created, starts a background thread, similar to that below:
class Test
{
boost::thread thread_;
void Process()
{
...
}
public:
Test()
{
thread_ = boost::thread(Process);
}
}
I can’t get it to compile, the error is “No matching function for call to boost::thread::thread(unresolved function type)”. When I do this outside of a class it works fine. How can I get the function pointer to work?
You should initialize
thread_as:Processis a member non-static method of classTest. You can either:Processas static.Processon.If you declare
Processas static, the initializer should just beOtherwise, you can bind an instance of
Testusing Boost.Bind: