std::future::share(3)
π NAME
okay so this is the std::future::share(3) page from the C++ Standard Libary, and it's literally about moving a future's shared state into a std::shared_future so multiple besties can reference it. no cap, it's giving very specific but very iconic C++ energy π
β¨ Synopsis
std::shared_future<T> share() noexcept;
Transfers the shared state of *this, if any, to a std::shared_future object. Multiple std::shared_future objects may reference the same shared state, which is not possible with std::future. After calling share on a std::future, valid() == false.
lowkey important: once you callshareon astd::future, that future is not valid anymore.valid() == false, periodt.
π Parameters
(none) β not a single parameter, bestie. zero. nada. the parameter list is empty and it's thriving π«Ά
π Return value
A std::shared_future object containing the shared state previously held by *this, if any, constructed as if by std::shared_future<T>(std::move(*this)).
π¦ Example
This section is incomplete.
Reason: no example.
not me reading βThis section is incompleteβ in the actual docs π no example exists on this page, so we're not making one up. facts are facts.
πΈ Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
LWG 2556β applied toC++11; behavior as published:share()requiresvalid()to be true; correct behavior: requirement removed and madenoexcept.
π See also
shared_future(C++11) β waits for a value (possibly referenced by other futures) that is set asynchronously (class template).
π Category
- Todo β no example
source/version + date check: http://cppreference.com, 2024.06.10, page std::future::share(3) β bye bestie, go share that state responsibly β¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms