A capturing lambda can be a coroutine, but you have to save your captures while you still can
Will you use one?
A capturing lambda can be a coroutine, but you have to save your captures while you still can
by Raymond Chen
From the article:
We saw some time ago that capturing lambdas which are coroutines result in lifetime issues because the lambda itself returns at the first suspension point, at which point there’s a good chance it will be destructed. After that point, any attempt by the lambda body to access those captured variables is a use-after-free bug...

The fourth keynote from CppCon 2021 is now publicly available via JetBrains, our video sponsor:
The third keynote from CppCon 2021 is now publicly available via JetBrains, our video sponsor: