<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1629</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="1629"></A><H4>1629.
  
Can a closure class be a literal 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>C++14
 &#160;&#160;&#160;

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>2012-02-22<BR><BR>


<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3903.html#ES9">N3690 comment
  ES&#160;9<BR></A>

<P>[Moved to DR at the February, 2014 meeting.]</P>

<P>The description of the characteristics of a closure class in
7.5.6 [<A href="https://wg21.link/expr.prim.lambda">expr.prim.lambda</A>] leaves open the possibility that such a
class might be a literal type, although it could also be a non-literal
type.  It would probably be good to specify that a closure class is not
a literal type, in the interests of portability.</P>

<P>On a related note, it might be wise to remove the implementation
freedom to make a closure class either a POD or not a POD; it seems
only to be an invitation for portability problems with no real
advantage.</P>

<P><B>Additional note, April, 2013:</B></P>

<P>Some have expressed the opinion that such portability issues are
just &#8220;par for the course,&#8221; and that specifying these
characteristics at this point might unnecessarily limit the ability
to extend the language in desirable directions at some point in the
future.  </P>

<P><B>Proposed resolution (April, 2013) [superseded]:</B></P>

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

<BLOCKQUOTE>

<P>...An implementation may define the closure type differently
from what is described below provided this does not alter
the observable behavior of the program other than by
changing:</P>

<UL>
<LI><P>the size and/or alignment of the closure type,</P></LI>

<LI><P>whether the closure type is trivially copyable (
Clause 11 [<A href="https://wg21.link/class">class</A>]),</P></LI>

<LI><INS>whether the closure type is a literal type
(6.9 [<A href="https://wg21.link/basic.types">basic.types</A>]),</INS></LI>

<LI><P>whether the closure type is a standard-layout class (
Clause 11 [<A href="https://wg21.link/class">class</A>]), or</P></LI>

<LI><P>whether the closure type is a POD class (
Clause 11 [<A href="https://wg21.link/class">class</A>]).</P></LI>

</UL>

</BLOCKQUOTE>

<P><B>Notes from the September, 2013 meeting:</B></P>

<P>At the suggestion of EWG, it was decided that closure types should
be specified as not literal, rather than being unspecified as in the
April, 2013 proposed resolution.  The issue has thus been returned to
"drafting" status.</P>

<P><B>Proposed resolution (January, 2014):</B></P>

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

<BLOCKQUOTE>

The type of the <I>lambda-expression</I> (which is also the
type of the closure object) is a unique, unnamed non-union
class type &#8212; called the closure type &#8212; whose
properties are described below. This class type
is <DEL>not</DEL> <INS>neither</INS> an aggregate
(9.5.2 [<A href="https://wg21.link/dcl.init.aggr">dcl.init.aggr</A>]) <INS>nor a literal type
(6.9 [<A href="https://wg21.link/basic.types">basic.types</A>])</INS>. The closure type is
declared...

</BLOCKQUOTE>

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