<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2845</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="2845"></A><H4>2845.
  
Make the closure type of a captureless lambda a structural type
</H4>
<B>Section: </B>7.5.6.2&#160; [<A href="https://wg21.link/expr.prim.lambda.closure">expr.prim.lambda.closure</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Barry Revzin
 &#160;&#160;&#160;

 <B>Date: </B>2023-12-29<BR>


<P>[Accepted as a DR at the March, 2024 meeting.]</P>



<P>
<A HREF="2542.html">Issue 2542</A> (approved in June, 2023) made
all closure types not be structural types, i.e. unsuitable for use as
non-type template parameters.  This causes an inconsistency with the
treatment of the pointer-to-function conversion for closure types with
no captures:</P>

<PRE>
  template &lt;auto V&gt;
  void foo() {}

  void bar() {
    foo&lt;[i = 3] { return i; }&gt;();   //<SPAN CLASS="cmnt"> #1: error</SPAN>
    foo&lt;[]{}&gt;();                    //<SPAN CLASS="cmnt"> #2: error</SPAN>
    foo&lt;+[]{}&gt;();                   //<SPAN CLASS="cmnt"> #3: OK, a function pointer is a structural type</SPAN>
  }
</PRE>

<P><B>Proposed resolution (approved by CWG 2024-02-02):</B></P>

<OL>
<LI>
<P>Change in 7.5.6.2 [<A href="https://wg21.link/expr.prim.lambda.closure#3">expr.prim.lambda.closure</A>] paragraph 3 as follows:</P>

<BLOCKQUOTE>

The closure type is not an aggregate type (9.5.2 [<A href="https://wg21.link/dcl.init.aggr">dcl.init.aggr</A>])
<DEL>and not</DEL> <INS>; it is</INS> a structural type
(13.2 [<A href="https://wg21.link/temp.param">temp.param</A>])
<INS>if and only if the lambda has no <I>lambda-capture</I></INS>. An
implementation may define the closure type differently from ...

</BLOCKQUOTE>
</LI>

<LI>
<P>Change in 13.6 [<A href="https://wg21.link/temp.type#2">temp.type</A>] paragraph 2 as follows:</P>

<BLOCKQUOTE>

Two values are <I>template-argument-equivalent</I> if they are of the
same type and
<UL>
<LI>...</LI>
<LI class="ins">they are of a closure type
(7.5.6.2 [<A href="https://wg21.link/expr.prim.lambda.closure">expr.prim.lambda.closure</A>]), or</LI>
<LI>they are of class type and their corresponding direct subobjects
and reference members are template-argument-equivalent.</LI>
</UL>

</BLOCKQUOTE>

</LI>
</OL>
<BR><BR>
</BODY>
</HTML>
