<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3119: Program-definedness of closure types</title>
<meta property="og:title" content="Issue 3119: Program-definedness of closure types">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3119.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++20">C++20</a> status.</em></p>
<h3 id="3119"><a href="lwg-defects.html#3119">3119</a>. Program-definedness of closure types</h3>
<p><b>Section:</b> 3.42 <a href="https://wg21.link/defns.prog.def.spec">[defns.prog.def.spec]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Hubert Tong <b>Opened:</b> 2018-06-09 <b>Last modified:</b> 2021-06-06</p>
<p><b>Priority: </b>2
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The description of closure types in 7.5.6.2 <a href="https://wg21.link/expr.prim.lambda.closure">[expr.prim.lambda.closure]</a> says:
</p>
<blockquote>
<p>
An implementation may define the closure type differently [&hellip;]
</p>
</blockquote>
<p>
The proposed resolution to LWG <a href="lwg-defects.html#2139" title="What is a user-defined type? (Status: C++20)">2139</a><sup><a href="https://cplusplus.github.io/LWG/issue2139" title="Latest snapshot">(i)</a></sup> defines a "program-defined type" to be a
</p>
<blockquote>
<p>
class type or enumeration type that is not part of the C++ standard library and not defined by the implementation,
or an instantiation of a program-defined specialization
</p>
</blockquote>
<p>
I am not sure that the intent of whether closure types are or are not program-defined types is clearly
conveyed by the wording.
</p>

<p><i>[2018-06-23 after reflector discussion]</i></p>

<p>Priority set to 2</p>

<p><i>[2018-08-14 Casey provides additional discussion and a Proposed Resolution]</i></p>

<p>
We use the term "program-defined" in the library specification to ensure that
two users cannot create conflicts in a component in namespace <code>std</code> by
specifying different behaviors for the same type. For example, we allow users to
specialize <code>common_type</code> when at least one of the parameters is a
program-defined type. Since two users cannot define the same program-defined
type, this rule prevents two users (or libraries) defining the same
specialization of <code>std::common_type</code>.
</p><p>
Since it's guaranteed that even distinct utterances of identical lambda
expressions produce closures with distinct types
(7.5.6.2 <a href="https://wg21.link/expr.prim.lambda.closure">[expr.prim.lambda.closure]</a>), adding closure types to our term
"program-defined type" is consistent with the intended use despite that such
types are technically defined by the implementation.
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4762">N4762</a>.</p>

<ul>
<li><p>Modify 3.43 <a href="https://wg21.link/defns.prog.def.type">[defns.prog.def.type]</a> as follows:</p>
<blockquote>
<b>program-defined type</b><br/>
class type or enumeration type that is not part of the C++ standard library and
not defined by the implementation <ins>(except for closure types
(7.5.6.2 <a href="https://wg21.link/expr.prim.lambda.closure">[expr.prim.lambda.closure]</a>) for program-defined lambda
expressions)</ins>, or an instantiation of a program-defined specialization
</blockquote>
</li>
</ul>
</blockquote>

<p><i>[2018-08-23 Batavia Issues processing]</i></p>

<p>Updated wording</p>

<p><i>[2018-11 San Diego Thursday night issue processing]</i></p>

<p>Status to Ready.</p>


<p id="res-3119"><b>Proposed resolution:</b></p>

<p>This wording is relative to <a href="https://wg21.link/n4762">N4762</a>.</p>

<ul>
<li><p>Modify 3.43 <a href="https://wg21.link/defns.prog.def.type">[defns.prog.def.type]</a> as follows:</p>
<blockquote>
<b>program-defined type</b><br/>
<ins>non-closure </ins>class type or enumeration type that is not part of the
C++ standard library and not defined by the implementation,
<ins>or a closure type of a non-implementation-provided lambda expression, </ins>
or an instantiation of a program-defined specialization
</blockquote>
</li>
</ul>






</body>
</html>
