How can I pass class method to std::async
?
Example:
#include <future>
#include <iostream>
class ExampleClass { public:
void exampleMethod() {
std::cout << "foo\n";
}
auto initializeExampleMethod() {
return std::async(std::launch::async, &this->handler, &this);
}
}
In Visual Studio Code (on Windows) it shows error a pointer to a bound function may only be used to call the function
. How can I solve this easily?