Skip to content

Commit 2658c74

Browse files
committed
Merge 2017-07 CWG Motion 9
2 parents 8de0452 + 57b2c0f commit 2658c74

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

source/declarations.tex

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@
15461546
from an initializer. The \tcode{auto}
15471547
\grammarterm{type-specifier} is also used to
15481548
introduce a function type having a \grammarterm{trailing-return-type} or to
1549-
signify that a lambda is a generic lambda (\ref{expr.prim.lambda.closure}).
1549+
signify that a lambda is a generic lambda (\ref{expr.prim.lambda}).
15501550
The \tcode{auto} \grammarterm{type-specifier} is also used to introduce a
15511551
structured binding declaration (\ref{dcl.struct.bind}).
15521552

@@ -1563,17 +1563,6 @@
15631563
deduced from non-discarded \tcode{return} statements, if any, in the body
15641564
of the function~(\ref{stmt.if}).
15651565

1566-
\pnum
1567-
If the \tcode{auto} \grammarterm{type-specifier} appears as one of the
1568-
\grammarterm{decl-specifier}{s} in the \grammarterm{decl-specifier-seq} of a
1569-
\grammarterm{parameter-declaration} of a \grammarterm{lambda-expression}, the
1570-
\indextext{generic lambda!definition of}%
1571-
lambda is a \term{generic lambda}~(\ref{expr.prim.lambda.closure}). \begin{example}
1572-
\begin{codeblock}
1573-
auto glambda = [](int i, auto a) { return i; }; // OK: a generic lambda
1574-
\end{codeblock}
1575-
\end{example}
1576-
15771566
\pnum
15781567
The type of a variable declared using \tcode{auto} or \tcode{decltype(auto)} is
15791568
deduced from its initializer.

source/expressions.tex

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@
596596

597597
\begin{bnf}
598598
\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
600601
\end{bnf}
601602

602603
\begin{bnf}
@@ -659,6 +660,19 @@
659660
\end{codeblock}
660661
\end{example}
661662

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+
662676
\rSec3[expr.prim.lambda.closure]{Closure types}%
663677

664678
\pnum
@@ -700,7 +714,9 @@
700714
respectively.
701715
For a generic lambda, the closure type has a public inline function call
702716
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
704720
\grammarterm{template-parameter} for each occurrence of \tcode{auto} in the
705721
lambda's \grammarterm{parameter-declaration-clause}, in order of appearance.
706722
The invented type \grammarterm{template-parameter} is a parameter pack if
@@ -808,7 +824,7 @@
808824
For a generic lambda with no \grammarterm{lambda-capture}, the closure type has a
809825
conversion function template to
810826
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
812828
parameter types, as the function call operator template. The return type of
813829
the pointer to function shall behave as if it were a
814830
\grammarterm{decltype-specifier} denoting the return type of the corresponding

0 commit comments

Comments
 (0)