std::corout...le::promise(3)

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

πŸ’… std::coroutine_handle::promise πŸ’…

okay so this is the std::corout...le::promise(3) page from the C++ Standard Libary manual, and we're talking about the promise accessor on std::coroutine_handle. it's giving tiny function, big coroutine energy. πŸ¦‹πŸ’–

🌸 NAME 🌸

std::coroutine_handle::promise β€” literally std::coroutine_handle::promise. that's the whole NAME, bestie. periodt. πŸ’…

✨ Synopsis ✨

Member of the primary template

Promise& promise() const;

(since C++20)

Member of specialization std::coroutine_handle<std::noop_coroutine_promise>

std::noop_coroutine_promise& promise() const noexcept;

(since C++20)

It obtains a reference to the promise object. that's the vibe. 🫢

⚠️ Undefined behavior alert: the behavior is undefined if *this does not refer to a coroutine whose promise object has not been destroyed. like, do not mess with this unless that condition is true, bestie. 😭

This function is not provided for the specialization std::coroutine_handle<>. not here, not today. πŸ™ˆ

🌸 Parameters 🌸

None. zero. nada. (none) β€” no parameters at all. πŸŽ€

πŸŽ€ Return value πŸŽ€

A reference to the promise object. that's the whole return, and it ate. πŸ’–

πŸ¦‹ Notes πŸ¦‹

The promise object of a no-op coroutine is not destroyed as long as there is some std::noop_coroutine_handle referring to the coroutine. lowkey important, highkey iconic. πŸ¦‹

🌈 See also 🌈

  • from_promise β€” creates a coroutine_handle from the promise object of a coroutine. it's [static], it's (C++20), and it's a (public static member function). πŸ‘‘βœ¨

source/version/date shoutout: http://cppreference.com Β· 2024.06.10 Β· std::corout...le::promise(3) β€” bye bestie, mwah πŸ’‹πŸ’–

πŸ“¦ where this page comes from