How does std::async “store” an arbitrary exception?
问题 I am not able to understand how is it possible for std::async to store any exception, not just something derived from std::exception . I played around with the code below #include <iostream> #include <future> #include <chrono> void f() { std::cout << "\t\tIn f() we throw an exception" << std::endl; throw 1; // throw an int } int main() { std::future<void> fut = std::async(std::launch::async, f); std::cout << "Main thread sleeping 1s..." << std::endl; std::this_thread::sleep_for(std::chrono: