class Foo
{
private:
std::unique_ptr<Bar>& bar;
int retVal;
std::future<int> myFuture = std::async(std::launch::async, &Foo::bar->myMethod, this);
Foo(std::unique_ptr<Bar>& bar_) : bar(bar_) {}
}
Run Code Online (Sandbox Code Playgroud)
我相信这总结了这个话题,因为这不起作用.我怎样才能推出myFuture上Bar::myMethod?
你需要命名Bar::myMethod,并传递(适当的cv)Bar *或Bar &.这看起来像
std::async(std::launch::async, &Bar::myMethod, bar.get());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
87 次 |
| 最近记录: |