#include <functional>
#include <future>
#include <iostream>
class A
{
public:
int run(int a, const std::string& s)
{
std::cout << "a=" << a << ",s=" << s << std::endl;
return a+1;
}
};
int main()
{
A a;
auto f = std::bind(&A::run,&a,5,std::placeholders::_1);
std::packaged_task<int(const std::string&)> pt(std::move(f));
auto fut = std::async(std::move(pt),"test");
/// std::cout << fut.get() << std::endl; Does not compile
fut.get();
return 0;
}
Why fut.get() is returning void ? A::run is defined to return int and hence it should return int instead of void.
Aucun commentaire:
Enregistrer un commentaire