I recently had a need for a recursive C++ lambda that captures variables. This isn't possible in the intuitive way; you get:
error: variable 'someVar' declared with deduced type 'auto' cannot appear in its own initializer.
It turns out you can achieve this (albeit a bit horribly) by passing the lambda to itself! See this article for details: artificial-mind.net/blog/2020/…

Peter Vágner reshared this.