Search code examples
c++lambdalanguage-lawyerc++14

Is (or will be) the use of familiar template syntax in lambda expressions allowed?


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 ?

Solution

  • 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.