boost:thread - compiler error

后端 未结 3 1330
刺人心
刺人心 2021-01-15 06:25

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:15

    Member functions have a this pointer as the first argument. Since there is a boost::thread constructor that accepts function arguments, you don't need to use boost::bind. This will also work:

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

    If your function requires arguments, you can put them after the this pointer argument.

提交回复
热议问题