myWallJSON
myWallJSON

Reputation: 9502

Why C++14 Generic lambdas require auto in parameters specification?

I look at Generic lambdas and cant get it - why keep type declaration at all? why not (x, y)? If compiler vendors will have to support (auto a, auto b) Are there any problems supporting simple (a, b)?

Upvotes: 3

Views: 306

Answers (1)

Daniel Frey
Daniel Frey

Reputation: 56863

The problem is that you are also allowed to leave out the parameter's name. If the compiler sees (a,b) and a and b are also valid types, what should that mean? (a /*dummy_a*/, b /*dummy_b*/) or (auto a, auto b)? With having to type auto explicitly, it is no longer ambiguous.

Upvotes: 18

Related Questions