mercredi 11 mars 2015

How do I create a packaged_task with a member function?

On the program below, I'm trying to create a packaged_task with a member function:



#include <future>
using namespace std;

struct S
{
int calc(int& a)
{
return a*a;
}
};

int main()
{
S s;
auto bnd = std::bind(&S::calc, s);
std::packaged_task<int(int&)> task( bnd);
return 0;
}


Unfortunately the attempt results in an error.


How can this be done??


Aucun commentaire:

Enregistrer un commentaire