Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

c++ - 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 ?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...