I wanted to use boost::thread in my program, but get the following compiler error (Visual Studio 2005):
Error 1 **error C2064**: term does not evaluate to a function taking 0 arguments d:\...\boost_1_37_0\boost\thread\detail\thread.hpp 56
Therefore I tried to recreate the problem in a small program and modified the working Hello World example from this site.
My test code now looks like this. Why is it not working inside a class?:
#include <boost/thread.hpp> #include <iostream> class HelloWorld { public: void hello(); void entry(); }; void HelloWorld::entry() { boost::thread thrd(&HelloWorld::hello); thrd.join(); } void HelloWorld::hello() { std::cout << 'Hello world, I'm a thread!' << std::endl; } int main(int argc, char* argv[]) { HelloWorld *bla = new HelloWorld; bla->entry(); return 0; }
Try it like this – the boost::thread constructor is expecting a boost::function0 (which a function pointer is, but a member function pointer isn’t, due to the this pointer).