fork download
  1. #include <iostream>
  2. #include <future>
  3. #include <chrono>
  4. using namespace std;
  5.  
  6. int main() {
  7. auto start = chrono::system_clock::now();
  8. auto f = async(launch::async, [=](){
  9. this_thread::sleep_for(chrono::seconds(3));
  10. });
  11. chrono::duration<double> diff = chrono::system_clock::now() - start;
  12. cout << "Elapsed " << diff.count() << " seconds" << endl;
  13. return 0;
  14. }
Success #stdin #stdout 0s 4360KB
stdin
Standard input is empty
stdout
Elapsed 1.6499e-05 seconds