std::corout...from_promise(3)

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

πŸ¦‹ std::corout...from_promise(3) πŸ¦‹

okay bestie, welcome to the C++ Standard Libary manual β€” yes, that’s literally the manual name, spelling and all, and this page is all about one very specific little coroutine-handle maker. 🫢


πŸ’– NAME πŸ’–

  • std::coroutine_handle::from_promise β€” std::coroutine_handle::from_promise

yeah, the NAME line says it twice, and honestly? iconic repetition, no notes. πŸ’…


✨ Synopsis ✨

static coroutine_handle from_promise( Promise& p );  (since C++20)

Creates a coroutine_handle from the promise object of a coroutine. The created coroutine_handle refers the coroutine, and promise() returns a reference to p. πŸŽ€

⚠️ The behavior is undefined if p is not a reference to a promise object. That’s the dramatic part, bestie β€” do not play with that. 😭

This function is only provided for the primary template, i.e. specializations std::coroutine_handle<> and std::coroutine_handle<std::noop_coroutine_promise> do not have this function. The way that it’s primary-template-only is giving very exclusive club energy. πŸ‘‘


🌸 Parameters 🌸

  • p β€” promise object of a coroutine to refer

πŸŽ€ Return value πŸŽ€

A coroutine_handle referring the given coroutine. ✨


πŸ¦‹ Example πŸ¦‹

This section is incomplete

Reason: no example

not me reading β€œno example” and feeling personally attacked πŸ˜­πŸ™ˆ β€” but fr fr, that’s what it says.


πŸ‘‘ See also πŸ‘‘

  • constructor β€” constructs a coroutine_handle object (C++20) (public member function)
  • from_address β€” imports a coroutine from a pointer [static] (C++20) (public static member function)
  • noop_coroutine β€” creates a coroutine handle that has no observable effects when resumed or destroyed (C++20) (function)

🏷️ Category 🏷️

  • Todo no example

that’s the whole category, lowkey minimal, highkey honest. πŸ’€


mwah πŸ’‹ β€” source/version: http://cppreference.com, dated 2024.06.10, and the footer tag is std::corout...from_promise(3). bye bestie, go handle your coroutines responsibly 🫢🌈

πŸ“¦ where this page comes from