std::experi...onal_future(3)

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

πŸ’… std::experimental::make_exceptional_future πŸ’…

okay so bestie, this one's from the C++ Standard Library manual (yes, the cppreference one, we stan ✨) and the NAME is literally std::experimental::make_exceptional_future β€” that's the function, that's the whole vibe, no notes πŸŽ€


✨ SYNOPSIS ✨

Defined in header <experimental/future>

template< class T >                                         (1)
(concurrency TS)
future<T> make_exceptional_future( std::exception_ptr ex );

template< class T, class E >                                (2)
(concurrency TS)
future<T> make_exceptional_future( E ex );

so there's two overloads and both of them live in the concurrency TS, iykyk πŸ¦‹

  1. Overload (1) β€” makes a shared state of type T that's immediately ready and stores the exception pointer ex inside it, then hands you back a future associated with that shared state, as if by:
promise<T> p; p.set_exception(ex); return p.get_future();
⚠️ lowkey important: the behavior is undefined if ex is null. like, undefined undefined. don't do it πŸ™ˆ
  1. Overload (2) β€” makes a shared state of type T that's immediately ready and stores an exception pointer created from ex, then returns a future associated with that shared state, as if by:
promise<T> p;
p.set_exception(std::make_exception_ptr(ex)); return
p.get_future();

same immediate-ready energy, just built from ex instead of a raw std::exception_ptr, periodt πŸ’…


πŸ’– RETURN VALUE πŸ’–

a future object all cozy and associated with the shared state that was just created. that's it. that's the return. she's ready instantly 🌸


πŸ” SEE ALSO πŸ”

  • make_ready_future β€” produces a future that is ready immediately and holds the given value (this one's also part of the concurrency TS), and it's a function template 🫢

so yeah, that's the whole page, no cap. and before you go β€” this lil beauty is served fresh from http://cppreference.com, dated 2024.06.10, under the std::experi...onal_future(3) banner. go make some exceptional futures bestie, you got this πŸ’œπŸŒˆ

πŸ“¦ where this page comes from