P
Size: a a a
ПК
AB
AB
КМ
VU
VS
AS
When a coroutine begins execution, it performs the following:(c) https://en.cppreference.com/w/cpp/language/coroutines
allocates the coroutine state object using operator new (see below)
copies all function parameters to the coroutine state: by-value parameters are moved or copied, by-reference parameters remain references (and so may become dangling if the coroutine is resumed after the lifetime of referred object ends)
calls the constructor for the promise object. If the promise type has a constructor that takes all coroutine parameters, that constuctor is called, with post-copy coroutine arguments. Otherwise the default constructor is called.
calls promise.get_return_object() and keeps the result in a local variable. The result of that call will be returned to the caller when the coroutine first suspends. Any exceptions thrown up to and including this step propagate back to the caller, not placed in the promise.
calls promise.initial_suspend() and co_await's its result. Typical Promise types either return a suspend_always, for lazily-started coroutines, or suspend_never, for eagerly-started coroutines.
when co_await promise.initial_suspend() resumes, starts executing the body of the coroutine
AS
AS
VU