void func() {
std::future<int> fut = std::async(std::launch::async, []{
std::this_thread::sleep_for(std::chrono::seconds(10));
return 8;
});
return;
}
Let's say that I have such a function. An object fut of std::future<int> is initialized with a std::async job, which will return an integer in the future. But the fut will be immediately released after the function func returns.
Is there such an issue: When the std::async job returns and try to assign the 8 to the object fut, the object has already been released...
If so, a coredump about SIGSEGV may occur...
Am I right about it? Or std::future has some mechanism to avoid this issue?