auto
for lambda parameters exists to cover the fact that there is no way to specify generic types using template
(the syntax would be strange). Well, that has changed in c ++ 20 , with the possibility of specifying them within lambda :
auto sum = []<typename T, typename U>(T a, U b) { return a + b; };
There is no auto
for normal function parameters, because you can already specify generic types with template
s:
template <typename T, typename U>
auto sum(T a, U b) -> decltype(a + b) { return a + b; }
It is a matter of lack of proposals to the committee itself. As far as I know, only an old TS of concepts proposed this use of auto
, but it was removed.