diff --git a/source/expressions.tex b/source/expressions.tex index 35ee3fd888..d988c16071 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -1574,18 +1574,6 @@ If a \grammarterm{lambda-expression} does not include a \grammarterm{lambda-declarator}, it is as if the \grammarterm{lambda-declarator} were \tcode{()}. -The lambda return type is \tcode{auto}, which is replaced by the -type specified by the -\grammarterm{trailing-return-type} if provided and/or deduced from -\tcode{return} statements as described in~\ref{dcl.spec.auto}. -\begin{example} -\begin{codeblock} -auto x1 = [](int i){ return i; }; // OK: return type is \tcode{int} -auto x2 = []{ return { 1, 2 }; }; // error: deducing return type from \grammarterm{braced-init-list} -int j; -auto x3 = []()->auto&& { return j; }; // OK: return type is \tcode{int\&} -\end{codeblock} -\end{example} \pnum A lambda is a \defn{generic lambda} @@ -1636,18 +1624,43 @@ The closure type for a \grammarterm{lambda-expression} has a public inline function call operator (for a non-generic lambda) or function call operator template (for a generic lambda)\iref{over.call} -whose parameters and return type -are described by the \grammarterm{lambda-expression}'s -\grammarterm{parameter-declaration-clause} and \grammarterm{trailing-return-type} -respectively, and whose -\grammarterm{template-parameter-list} consists of -the specified \grammarterm{template-parameter-list}, if any. -The \grammarterm{requires-clause} of the function call operator template +whose: +\begin{itemize} +\item \grammarterm{parameter-declaration-clause} is the \grammarterm{lambda-declarator}'s +\grammarterm{parameter-declaration-clause}, + +\item return type is \tcode{auto}, + +\item \grammarterm{trailing-return-type} is the \grammarterm{lambda-declarator}'s +\grammarterm{trailing-return-type}, if any, + +\item trailing \grammarterm{requires-clause} is the \grammarterm{lambda-declarator}'s +\grammarterm{requires-clause}, if any, + +\item \grammarterm{template-parameter-list} is the \grammarterm{lambda-expression}'s +\grammarterm{template-parameter-list}, if any, and + +\item \grammarterm{requires-clause} in the \grammarterm{template-head} is the \grammarterm{requires-clause} immediately following -\tcode{<}~\grammarterm{template-parameter-list}{}~\tcode{>}, if any. -The trailing \grammarterm{requires-clause} of the function call operator -or operator template is the \grammarterm{requires-clause} -of the \grammarterm{lambda-declarator}, if any. +\tcode{<}~\grammarterm{template-parameter-list}{}~\tcode{>} +in the \grammarterm{lambda-expression}, if any. + +\end{itemize} + +\begin{note} +The actual return type will be the type specified by the +\grammarterm{trailing-return-type} if provided and/or deduced from +\tcode{return} statements as described in~\ref{dcl.spec.auto}. +\begin{example} +\begin{codeblock} +auto x1 = [](int i){ return i; }; // OK: return type is \tcode{int} +auto x2 = []{ return { 1, 2 }; }; // error: deducing return type from \grammarterm{braced-init-list} +int j; +auto x3 = []()->auto&& { return j; }; // OK: return type is \tcode{int\&} +\end{codeblock} +\end{example} +\end{note} + \begin{note} The function call operator template for a generic lambda might be an abbreviated function template\iref{dcl.fct}.