mercredi 25 mars 2015

pass parameter in std::async or in std::bind?

Here is my class



class Foo
{
public:
void foo(const std::string&);
};

int main()
{
Foo* pFoo = new Foo();
std::string str = "string";
//If I want to start an async task, I could do this:
std::async(std::launch::async, std::bind(&Foo::foo, pFoo, std::placeholders::_1), str);
//or do this:
std::async(std::launch::async, std::bind(&Foo::foo, pFoo, str));
}


So what's the difference?Which way is safer to use?


Aucun commentaire:

Enregistrer un commentaire