Header Reference: <future>
Header Reference: <future>
Futures, promises, packaged tasks, async launch, and related asynchronous result-passing facilities from <future>.
Header Reference: <future>
Futures, promises, packaged tasks, async launch, and related asynchronous result-passing facilities from <future>.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
Header reference pages are meant to answer a practical question quickly: what this header provides, when to reach for it, and which usage rules are easiest to get wrong.
<future>std::future<T>std::shared_future<T>std::promise<T>std::packaged_taskstd::asyncstd::launchstd::future_statusUse <future> when asynchronous work must return a value, propagate an exception, or signal completion to another execution context.
std::promise to fulfill a result from worker codestd::packaged_taskstd::async for simple task launching when policy and implementation behavior are acceptablestd::async launch policy to avoid surprising deferred execution.#include <future>
int main() {
auto fut = std::async(std::launch::async, [] { return 42; });
return fut.get();
}