r/cpp • • Dec 18 '25

The Lambda Coroutine Fiasco

https://github.com/scylladb/seastar/blob/master/doc/lambda-coroutine-fiasco.md

It's amazing C++23's "deducing this" could solve the lambda coroutine issue, and eliminate the previous C++ voodoo.

44 Upvotes

22 comments sorted by

View all comments

Show parent comment

0

u/efijoa Dec 18 '25 edited Dec 18 '25

That’s the problem: taking ownership of a coroutine lambda is a very dangerous operation. Once the lambda is invoked and yields a continuation, the coroutine frame will reference the lambda's this pointer. At this point, the future state (or the lambda captures) could not even be moved to another place... and we all know C++ doesn't have a Pin type.

Another subtle factor might be related with the seastar future originally comes from the chained future style, i'm not sure if it affected the current design.