|
596 | 596 |
|
597 | 597 | \begin{bnf}
|
598 | 598 | \nontermdef{lambda-expression}\br
|
599 |
| - lambda-introducer lambda-declarator\opt compound-statement |
| 599 | + lambda-introducer lambda-declarator\opt{} compound-statement\br |
| 600 | + lambda-introducer \tcode{<} template-parameter-list \tcode{>} lambda-declarator\opt{} compound-statement |
600 | 601 | \end{bnf}
|
601 | 602 |
|
602 | 603 | \begin{bnf}
|
|
659 | 660 | \end{codeblock}
|
660 | 661 | \end{example}
|
661 | 662 |
|
| 663 | +\pnum |
| 664 | +A lambda is a \defn{generic lambda} |
| 665 | +if the \tcode{auto} \grammarterm{type-specifier} appears as one of the |
| 666 | +\grammarterm{decl-specifier}{s} in the \grammarterm{decl-specifier-seq} of a |
| 667 | +\grammarterm{parameter-declaration} of the \grammarterm{lambda-expression}, |
| 668 | +or if the lambda has a \grammarterm{template-parameter-list}. |
| 669 | +\begin{example} |
| 670 | +\begin{codeblock} |
| 671 | +int i = [](int i, auto a) { return i; }(3, 4); // OK: a generic lambda |
| 672 | +int j = []<class T>(T t, int i) { return i; }(3, 4); // OK: a generic lambda |
| 673 | +\end{codeblock} |
| 674 | +\end{example} |
| 675 | + |
662 | 676 | \rSec3[expr.prim.lambda.closure]{Closure types}%
|
663 | 677 |
|
664 | 678 | \pnum
|
|
700 | 714 | respectively.
|
701 | 715 | For a generic lambda, the closure type has a public inline function call
|
702 | 716 | operator member template~(\ref{temp.mem}) whose
|
703 |
| -\grammarterm{template-parameter-list} consists of one invented type |
| 717 | +\grammarterm{template-parameter-list} consists of |
| 718 | +the specified \grammarterm{template-parameter-list}, if any, |
| 719 | +to which is appended one invented type |
704 | 720 | \grammarterm{template-parameter} for each occurrence of \tcode{auto} in the
|
705 | 721 | lambda's \grammarterm{parameter-declaration-clause}, in order of appearance.
|
706 | 722 | The invented type \grammarterm{template-parameter} is a parameter pack if
|
|
808 | 824 | For a generic lambda with no \grammarterm{lambda-capture}, the closure type has a
|
809 | 825 | conversion function template to
|
810 | 826 | pointer to function. The conversion function template has the same invented
|
811 |
| -\grammarterm{template-parameter-list}, and the pointer to function has the same |
| 827 | +template parameter list, and the pointer to function has the same |
812 | 828 | parameter types, as the function call operator template. The return type of
|
813 | 829 | the pointer to function shall behave as if it were a
|
814 | 830 | \grammarterm{decltype-specifier} denoting the return type of the corresponding
|
|
0 commit comments