How to use reference wrapping for a thread involving a member function of user defined class returning a non void type(c++)
问题 I'm having trouble making the wait/get future mechanism work with a member function of user defined class returning a non-void type. I wrote a very simple example below, the reference wrapping inside the instruction std::future<int> fut = std::async( &BasicClass::funcInt, std::ref(anObject) ); fails at compile time #include <iostream> // cout #include <future> // async, future using std::cout; using std::async; using std::future; class BasicClass { public: int funcInt(){return 119;} void