Although the two are functionally equivalent, they are the features of C++14 and C++20, namely generic lambda and template syntax for generic lambdas, which means that the latter is only well-formed in C++20.
Compared to the auto
which can accept any type, the latter can make lambda accept a specific type, for example:
[]<class T>(const std::vector<T>& x){};
In addition, it also enables lambda to forward parameters in a more natural form:
[]<class... Args>(Args&&... args) {
return f(std::forward<Args>(args)...);
};
You can get more details through the original paper P0428.