boost:thread - compiler error

后端 未结 3 1493
刺人心
刺人心 2021-01-15 06:59

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 t         


        
3条回答
  •  隐瞒了意图╮
    2021-01-15 07:18

    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).

    void HelloWorld::entry()
    {
        boost::thread thrd(boost::bind(&HelloWorld::hello,this));
        thrd.join();
    }
    

提交回复
热议问题