Is it still valid when the variable passed to `std::async` is out of scope?
Is the code snippet below legal? What worries me is when factorial is invoked the fut_num may be already out of scope. #include <future> #include <vector> #include <iostream> //int factorial(std::future<int> fut) //works, because there is a move constructor int factorial(std::future<int>&& fut) { int res = 1; int num = fut.get(); for(int i=num; i>1; i–) {… Read More Is it still valid when the variable passed to `std::async` is out of scope?