<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2121</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="2121"></A><H4>2121.
  
More flexible lambda syntax
</H4>
<B>Section: </B>7.5.6.1&#160; [<A href="https://wg21.link/expr.prim.lambda.general">expr.prim.lambda.general</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD6
 &#160;&#160;&#160;

 <B>Submitter: </B>EWG
 &#160;&#160;&#160;

 <B>Date: </B>2015-05-06<BR>


<P>[Adopted at the February, 2021 meeting as paper P1102R2.]</P>

<P>The grammar in 7.5.6 [<A href="https://wg21.link/expr.prim.lambda#1">expr.prim.lambda</A>] paragraph 1 allows
for omitting the the parameter list but only for a
non-<TT>mutable</TT> lambda, i.e., it does not permit</P>

<PRE>
    auto lambda = [] mutable { };
</PRE>

<P>This should be addressed, and the possibility of other
abbreviated forms should be considered, such as:</P>

<PRE>
    [] -&gt; float { return 42; }
    [] noexcept { foo(); }
</PRE>

<P><I>(This is EWG issue 135.)</I></P>

<P><B>Proposed resolution (May, 2015):</B></P>

<OL>
<LI><P>Change the grammar in 7.5.6 [<A href="https://wg21.link/expr.prim.lambda#1">expr.prim.lambda</A>] paragraph 1
as follows:</P></LI>

<UL>
<I>lambda-expression:</I>
<UL>
<I>lambda-introducer lambda-declarator<DEL><SUB>opt</SUB></DEL> compound-statement</I>
</UL>
<P>...</P>
<I>lambda-declarator:</I>
<UL>
<TT>(</TT> <I>parameter-declaration-clause</I> <TT>) mutable</TT><I><SUB>opt</SUB></I><BR>
<UL>
<I>exception-specification<SUB>opt</SUB> attribute-specifier-seq<SUB>opt</SUB> trailing-return-type<SUB>opt</SUB></I>
</UL>
<INS><TT>mutable</TT><I><SUB>opt</SUB> exception-specification<SUB>opt</SUB> attribute-specifier-seq<SUB>opt</SUB> trailing-return-type<SUB>opt</SUB></I></INS>
</UL>
</UL>

<LI><P>Change 7.5.6 [<A href="https://wg21.link/expr.prim.lambda#4">expr.prim.lambda</A>] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

<DEL>If a <I>lambda-expression</I> does not include
a <I>lambda-declarator</I>, it is as if
the <I>lambda-declarator</I> were <TT>()</TT>.</DEL> The lambda
return type...

</BLOCKQUOTE>

<LI><P>Change 7.5.6 [<A href="https://wg21.link/expr.prim.lambda#5">expr.prim.lambda</A>] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

The closure type for a non-generic <I>lambda-expression</I>
has a public inline function call operator
(12.4.4 [<A href="https://wg21.link/over.call">over.call</A>]) whose parameters and return
type are described by
the <I>lambda-expression</I>'s <I>parameter-declaration-clause</I>
and <I>trailing-return-type</I> respectively. For a generic
lambda... This function call operator or operator template is declared
<TT>const</TT> (11.4.3 [<A href="https://wg21.link/class.mfct.non.static">class.mfct.non.static</A>]) if and only if
the <DEL><I>lambda-expression</I>'s <I>parameter-declaration-clause</I>
is not followed by</DEL> <INS><I>lambda-declarator</I> does not
contain the keyword</INS> <TT>mutable</TT>. It is neither...

</BLOCKQUOTE>

</OL>

<P><B>Notes from the October, 2015 meeting:</B></P>

<P>Additional wording is needed in the proposed resolution
in paragraph 5 to handle the potential absence of the parameter
declaration clause.</P>

<BR><BR>
</BODY>
</HTML>
