On reaching the end of main , the std::future<int> object held in result is destroyed , which will wait for the task to finish, and then discard the result, cleaning up any resources used.
On reaching the end of main , the std::future<int> object held in result is destroyed , which will wait for the task to finish, and then discard the result, cleaning up any resources used.