C++14 introduced generic lambdas. While skimming through the related proposals I found N3418 by Faisal Vali, Herb Sutter and Dave Abrahams.
Therein section 2.2 is titled :
2.2 Allow the use of familiar template syntax in lambda expressions
and the following code examples include snippets like this one
[]<int N>(int (&a)[N]) {}
Since such things fail to compile (with gcc, clang and Visual Studio), some questions come up :
- Is this an implementation issue ?
- What stopped this part from being accepted ?
- Which is the proposal that finally brought generic lambdas into the language ?
The version of the paper that was accepted was N3649
, we can see this by going to Evolution Working Group(EWG) Completed Issue 16: N3649, N3560, N3559, N3418 Proposal for Generic (Polymorphic) Lambda Expressions:
Reviewed by EWG in Portland 2012, proceeding with a follow-up paper.
Accepted into the Working Draft in Bristol 2013, as N3649.
Bristol 2013: Do not re-open proposals 2.1 and 2.2 in N3560, they are
considered NAD. The proposals 2.3 and 2.4 are covered by N3649.
Note this references proposal 2.1
and 2.2
as being NAD(Not A Defect) and that they won't be reopened. N3560
was split off from N3418
which was the main proposal and proposal 2.1
in N3560
was:
Allow the use of familiar template syntax in lambda expressions
that paper notes proposal 2.1
was considered controversial:
We admit that supporting the full template parameter list feature
has been deemed controversial (the Portland 2012 straw-poll outcomes
were: 7 SF, 5 F, 3 N, 1 A, 1 SA 1 ) by a few committee members, and
therefore conclude this sub-section with some quotes from a committee
member who was not present in the room during EWG's discussion of
this feature in Portland.
and we can see that N3649 does not contain this proposal my guess from the quote in paper N3560
:
"
I think we need more than just
auto. I'm not sure how much more, but I think having just auto would be too limiting
".
was that auto was considered sufficient in the end which would be consistent with saying that the proposal is NAD
meaning the issue it attempted to resolve is not really an issue.
Note: I would comment on this but don't have the reputation to.
That precise construct that you quote works fine if I compile the following:
auto foo = []<int N>(int (&a)[N]) {};
with:
g++-4.9 -c foo.cpp -std=c++1y
However, using g++-4.8
or clang-3.6
both fail. Therefore, I would assume that it is an implementation issue. However, I am not familiar enough with the C++14 standard to know why/if it was accepted (for instance, g++ 4.9 supporting it may be non-standard).