std::experimental::future(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay so this is the std::experimental::future(3) page, from the C++ Standard Libary manual (yes bestie, β€œLibary,” we are keeping the header spelling exactly πŸ’€). The NAME situation is std::experimental::future β€” std::experimental::future, and honestly? main character energy. The star of the show is literally std::experimental::future.

πŸŒ€ Synopsis πŸŒ€

Defined in header <experimental/future>
template< class T > class future;       (1) (concurrency TS)
template< class T > class future<T&>;   (2) (concurrency TS)
template<> class future<void>;          (3) (concurrency TS)

The class template std::experimental::future extends std::future with the following operations:

  • an unwrapping constructor from future<future<T>>;
  • a member function is_ready to query whether the associated shared state is ready; and
  • a member function then to attach a continuation to the future.

However, there is no interoperation between std::experimental::future and std::future. none. zero. the two do not talk 😭.

🧩 Member functions 🧩

  • constructor β€” construct a future object (public member function)
  • is_ready β€” checks if the shared state is ready (public member function)
  • then β€” attaches a continuation to a future (public member function)
  • operator= β€” moves the future object (public member function)

πŸͺž Members identical to std::future πŸͺž

Note that share() returns a std::experimental::shared_future<T>. The behavior is otherwise identical.

πŸ’… Member functions πŸ’…

  • destructor β€” destructs the future object (public member function of std::future<T>)
  • share β€” transfers the shared state from *this to a shared_future and returns it (public member function of std::future<T>)

🍬 Getting the result 🍬

  • get β€” returns the result (public member function of std::future<T>)

🌑️ State 🌑️

  • valid β€” checks if the future has a shared state (public member function of std::future<T>)
  • wait β€” waits for the result to become available (public member function of std::future<T>)
  • wait_for β€” waits for the result, returns if it is not available for the specified timeout duration (public member function of std::future<T>)
  • wait_until β€” waits for the result, returns if it is not available until specified time point has been reached (public member function of std::future<T>)

πŸ™ˆ Example πŸ™ˆ

This section is incomplete.

Reason: no example.

bestie the example section is literally empty. it’s giving β€œwe’ll circle back” 😭. do not invent one, we are respecting the page.

πŸ‘€ See also πŸ‘€

  • shared_future (concurrency TS) β€” a version of std::shared_future enhanced with continuations and other features (class template)

🏷️ Category 🏷️

  • Todo no example

mwah πŸ’‹ that’s the whole page. source/version + date, for the record: http://cppreference.com, 2024.06.10, and it’s the std::experimental::future(3) page. periodt.

πŸ“¦ where this page comes from