Why i am getting No associated state error in below example. Could anyone tell any reason?

In below program i am getting error std::future_error: No associated state error.could anyone help why i am facing this error #include <iostream> #include <thread> #include <future> #include <chrono> #include <functional> void task(int& var, std::future<int>& refFuture) { std::packaged_task<int()> mytask{ [&](){var = 25; return var;}}; auto future = mytask.get_future(); mytask.make_ready_at_thread_exit(); refFuture = std::move(future); } int main() {… Read More Why i am getting No associated state error in below example. Could anyone tell any reason?