fork download
  1. #include <iostream>
  2. #include <future>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. class A {
  8. public:
  9. int x;
  10.  
  11. A(int x):x(x) {}
  12.  
  13. int test(int y) {
  14. return x+y;
  15. }
  16. };
  17.  
  18. int main() {
  19. A a(3);
  20. std::future<int> fut = std::async(&A::test, &a, 4);
  21.  
  22. cout << fut.get() << endl;
  23.  
  24. return 0;
  25. }
Runtime error #stdin #stdout #stderr 0s 3436KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error -1