Quantcast
Channel: How can I write a beautiful inline recursive lambda in C++? - Stack Overflow
Viewing all articles
Browse latest Browse all 6

How can I write a beautiful inline recursive lambda in C++?

$
0
0

As I know in C++17, I can write a recursive lambda like this:

auto dfs = [&](const auto &self, int x) -> void {    // ....    self(self, x);};dfs(dfs, 0);

Unfortunately, I have to endure one more parameter which is a bit ugly. And I doubt the possibility for the compiler to make it inline. Are there new options in new C++ standards? (C++20 or C++23)


Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>