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

Answer by Artyer for How to write a beautiful inline recursive lambda in C++?

$
0
0

You can use an explicit object parameter with a deduced type:

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

This is a C++23 feature


Viewing all articles
Browse latest Browse all 6