What is the lifetime of the arguments of std::async?
问题 It appears that arguments of a function executed via std::async share the lifetime of the future: #include <iostream> #include <future> #include <thread> struct S { S() { std::cout << "S() " << (uintptr_t)this << std::endl; } S(S&& s) { std::cout << "S(&&) " << (uintptr_t)this << std::endl; } S(const S& s) = delete; ~S() { std::cout << "~S() " << (uintptr_t)this << std::endl; } }; int main() { { std::cout << "enter scope" << std::endl; auto func = [](S&& s) { std::cout << "func " << (uintptr