fork download
  1. #include <cstdlib>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <thread>
  5. #include <future>
  6. #include <boost/functional/hash.hpp>
  7. #include <iostream>
  8.  
  9. int main()
  10. {
  11. std::vector<int> v(1ul<<27);
  12.  
  13. auto const chunk = v.size()/4;
  14.  
  15. auto f(begin(v)), l(end(v));
  16. std::generate(f, l, rand);
  17.  
  18. #if 1
  19. std::sort(f,l);
  20. #elif 0
  21. auto t1 = std::thread([&] () mutable { std::sort(f+chunk*0,f+chunk*1); } );
  22. auto t2 = std::thread([&] () mutable { std::sort(f+chunk*1,f+chunk*2); } );
  23. auto t3 = std::thread([&] () mutable { std::sort(f+chunk*2,f+chunk*3); } );
  24. auto t4 = std::thread([&] () mutable { std::sort(f+chunk*3,l ); } );
  25. t1.join();
  26. t2.join();
  27. t3.join();
  28. t4.join();
  29. #else
  30. auto f1 = std::async(std::launch::async, [&] () mutable { std::sort(f+chunk*0,f+chunk*1); } );
  31. auto f2 = std::async(std::launch::async, [&] () mutable { std::sort(f+chunk*1,f+chunk*2); } );
  32. auto f3 = std::async(std::launch::async, [&] () mutable { std::sort(f+chunk*2,f+chunk*3); } );
  33. auto f4 = std::async(std::launch::async, [&] () mutable { std::sort(f+chunk*3,l ); } );
  34. f1.get();
  35. f2.get();
  36. f3.get();
  37. f4.get();
  38. #endif
  39.  
  40. std::inplace_merge(f,f+chunk*1,f+chunk*2);
  41. std::inplace_merge(f+chunk*2,f+chunk*3,l);
  42. std::inplace_merge(f,f+chunk*2,l);
  43.  
  44. auto h = boost::hash_range(f,l);
  45. std::cout << h;
  46. }
  47.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:37: fatal error: boost/functional/hash.hpp: No such file or directory
compilation terminated.
stdout
Standard output is empty