fork download
  1. #include <iostream>
  2. #include <future>
  3. int main()
  4. {
  5. std::future<int> empty;
  6. try {
  7. int n = empty.get();
  8. } catch (const std::future_error& e) {
  9. const std::error_code eCode = e.code();
  10. char *sValue = (char*)e.what();
  11. std::cout << "Caught a future_error with code " << eCode.message()
  12. << " - what" << sValue << std::endl;
  13. }
  14. }
  15.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Caught a future_error with code No associated state - whatNo associated state