Is there a way to cancel/detach a future in C++11?
I have the following code: #include <iostream> #include <future> #include <chrono> #include <thread> using namespace std; int sleep_10s() { this_thread::sleep_for(chrono::seconds(10)); cout << "Sleeping Done\n"; return 3; } int main() { auto result=async(launch::async, sleep_10s); auto status=result.wait_for(chrono::seconds(1)); if (status==future_status::ready) cout << "Success" << result.get() << "\n"; else cout << "Timeout\n"; } This is supposed to wait 1 second, print "Timeout", and exit. Instead of exiting, it waits an additional 9 seconds, prints "Sleeping Done", and then segfaults. Is