C++ Logo

std-proposals

Advanced search

[std-proposals] Where await_transform = default?

From: Nikl Kelbon <kelbonage_at_[hidden]>
Date: Tue, 24 Sep 2024 10:12:19 +0400
Just where is it? Example:
You want to get handle from corouitne, writing awaiter:

struct get_handle {
??? handle;
await_ready();
await_suspend(...);
??? await_resume { return hadle }
}

So, code must know type of handle where its called. Only way to do it -
write await_transform in coroutine type.

So, programmer may write

each_of_my_coroutine_promises {
...
auto await_tranfsorm(get_handle_tag) { ... }
...
}

But now ALL await expressions are broken! Because compiler tries to call
await_transform for them, even if it is not a suitable function.

And its not fixable now. Programmer may try to emulate behavior of standard
(implicit) await transform, but it cannot 100% copy behavior of
compiler-inlined version, its verbose, its error-phone, it produces worse
code generation and force coroutine frame.

So, where await_transform() = default ?

Received on 2024-09-24 06:12:32