Advertisement
Carcigenicate

Future test

Mar 19th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <future>
  3.  
  4. using namespace std;
  5.  
  6. long factorial (int num) {
  7.     long prod = 1;
  8.     for (int i = 1; i <= num; ++i) {
  9.         prod *= i;
  10.     }
  11.     return prod;
  12. }
  13.  
  14. int main () {
  15.     future <long> fut = async (factorial, 100000);
  16.     fut.wait ();
  17.    
  18.     long ans = fut.get ();
  19.    
  20.     cout << ans << endl;
  21.    
  22.     cout << "Done\n";
  23. }
  24.  
  25. Error:
  26. /data/data/com.n0n3m4.droidc/files/temp.c: In function 'int main()':
  27. /data/data/com.n0n3m4.droidc/files/temp.c:19:16: error: variable 'std::future<long int> fut' has initializer but incomplete type
  28.   future <long> fut = async (factorial, 100000);
  29.                 ^
  30. compilation terminated due to -Wfatal-errors.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement