std::promise::get_future(3)

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

πŸ’– NAME πŸ’–

std::promise::get_future - std::promise::get_future

Okay bestie, welcome to std::promise::get_future(3) from the C++ Standard Libary manual. Yes, the page name is the name twice β€” self-titled queen behavior, periodt. This is the one about grabbing a future that’s associated with the same shared state as *this. Obsessed. πŸ¦‹

✨ Synopsis ✨

std::future<R> get_future();  (since C++11)

Returns a future object associated with the same shared state as *this. Literally the whole vibe.

An exception is thrown if *this has no shared state or if get_future has already been called. So don’t try to double-dip, bestie. To get multiple "pop" ends of the promise-future communication channel, use std::future::share. 🌸

Calling this function does not introduce data races with calls to set_value, set_exception, set_value_at_thread_exit, or set_exception_at_thread_exit (therefore they need not synchronize with each other). No cap β€” that’s the rule. πŸ”₯

πŸŽ€ Parameters πŸŽ€

None. Literally none. No parameters, no stress, no extra arguments to babysit. 😌

πŸ‘‘ Return value πŸ‘‘

A future referring to the shared state of *this. That’s it, that’s the return. πŸ’…

πŸ’€ Exceptions πŸ’€

std::future_error on the following conditions:

  • *this has no shared state. The error code is set to no_state.
  • get_future() has already been called on a promise with the same shared state as *this. The error code is set to future_already_retrieved.

Catch you later β€” this page’s source/version is http://cppreference.com, dated 2024.06.10 πŸ’–βœ¨

πŸ“¦ where this page comes from