Can std::async call std::function objects?
问题 Is it possible to call function objects created with std::bind using std::async. The following code fails to compile: #include <iostream> #include <future> #include <functional> using namespace std; class Adder { public: int add(int x, int y) { return x + y; } }; int main(int argc, const char * argv[]) { Adder a; function<int(int, int)> sumFunc = bind(&Adder::add, &a, 1, 2); auto future = async(launch::async, sumFunc); // ERROR HERE cout << future.get(); return 0; } The error is: No matching