class X
{
public:
int foo(int a,std::string const& b){std::cout<<a<<std::endl<<b<<std::endl;return 3;}
std::string bar(std::string const& a){std::cout<<a<<std::endl;return a;}
};
X x;
//在新线程中运行
auto f1 = std::async(std::launch::async,&X::foo,x,1,"hi");
//在wait()/get()中运行
auto f2 = std::async(std::launch::deferred,&X::bar,std::ref(x),"hello");
//运行f2
f2.wait();
//f2.get();