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

6

u/moncefm Dec 18 '25

It may not be _too_ hard to write a is_capture_lambda concept:

  • Write a is_lambda concept, e.g by parsing the output of __PRETTY_FUNCTION__ or boost::type_index (See this for some inspiration)
  • Then, you can leverage the '+' lambda trick to know if a lambda has captures or not:is_lambda<T> && !requires (T t) { +t; };