Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto as function argument

In C++14 something like this was made legal (for lambdas) :-

auto l = [](auto x, auto y) { return x+y; };

However something like this is still not legal :-

auto sum (auto x, auto y)
{
     return x+y;
}

My curiosity is why wasn't the second one added to the standard (though it is supposed to be added in C++17 hopefully) ? What were the pros & cons of the second one ?

like image 439
DevInd Avatar asked Jan 04 '16 14:01

DevInd


1 Answers

It wasn't added because it's another thing to add and time is not infinite. We cannot expect all useful enhancements to be added in one go, can we? As you have identified, it will be in C++17.

like image 82
Lightness Races in Orbit Avatar answered Sep 22 '22 02:09

Lightness Races in Orbit