Lambdas: From C++11 to C++20, Part 2
Since C++17, if possible, the standard defines for the lambda type implicitly as :
To recall, in C++17 a function has the following rules:
How about a more practical example? With C++20 we’ll get the following features:
In most of the cases the newly added features “cleanup” lambda use and they allow some advanced use cases. But if you call it with an parameter (like ) then you might get some hard-to-read error:
In C++20 we can write:
The above lambda resolves to a templated call operator:
The template parameter comes after the capture clause .
Source: www.bfilipek.com