std::corout...utine_handle(3)
β¨ NAME β¨
std::coroutine_handle::coroutine_handle β bestie, it's literally the constructor of std::coroutine_handle π
(and yeah, the page title is std::corout...utine_handle(3) from the C++ Standard Library manual, we're keeping it real π)
β¨ Synopsis β¨
Okay so here's the whole lineup, no cap:
constexpr coroutine_handle() noexcept; (1)
(since C++20)
constexpr coroutine_handle( std::nullptr_t ) noexcept; (2)
(since C++20)
coroutine_handle( const coroutine_handle& other ) = default; (3)
(since C++20)
coroutine_handle( coroutine_handle&& other ) = default; (4)
(since C++20)
So what do these do? They create a coroutine_handle that does not refer to a coroutine, or they copy an existing coroutine_handle. That's the whole vibe π¦
(1),(2)β these initialize the underlying addressptrtonullptr. After construction,address()returnsnullptr, and thecoroutine_handledoesn't refer to a coroutine, periodt. β οΈ Heads up though: these constructors are not declared for the specializationstd::coroutine_handle<std::noop_coroutine_promise>.(3),(4)β these copy the underlying address. The copy constructor and move constructor are equivalent to implicitly declared ones. Iconic, honestly πΈ
β¨ Parameters β¨
otherβ anothercoroutine_handleto copy π«Ά
β¨ Notes β¨
std::coroutine_handle<std::noop_coroutine_promise> is neither default constructible nor constructible from std::nullptr_t. Like, at all. π But bestie, don't panic β std::noop_coroutine can be used to create a new std::coroutine_handle<std::noop_coroutine_promise>. Slay.
Also, the static member functions from_promise and from_address can create a coroutine_handle too, iykyk π
β¨ See also β¨
from_promiseβ creates acoroutine_handlefrom the promise object of a coroutine.[static](C++20) (public static member function) βfrom_addressβ imports a coroutine from a pointer.[static](C++20) (public static member function) π₯noop_coroutine(C++20) β creates a coroutine handle that has no observable effects when resumed or destroyed. (function) β literally the chillest handle ever π
Go forth and construct responsibly, bestie. Thenullptrones arenoexcept, so at least you can't get caught lacking by an exception there ππ
That's the whole page, mwah π Sourced straight from http://cppreference.com, dated 2024.06.10 β and that header/footer combo was the std::corout...utine_handle(3) page itself, so you know it's legit. Catch you in the next manpage, babe π§π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms