<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2488: Placeholders should be allowed and encouraged to be constexpr</title>
<meta property="og:title" content="Issue 2488: Placeholders should be allowed and encouraged to be constexpr">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2488.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++17">C++17</a> status.</em></p>
<h3 id="2488"><a href="lwg-defects.html#2488">2488</a>. Placeholders should be allowed and encouraged to be <code>constexpr</code></h3>
<p><b>Section:</b> 22.10.15.5 <a href="https://wg21.link/func.bind.place">[func.bind.place]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Stephan T. Lavavej <b>Opened:</b> 2015-03-27 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>2
</p>
<p><b>View all other</b> <a href="lwg-index.html#func.bind.place">issues</a> in [func.bind.place].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<code>piecewise_construct</code> (22.3.5 <a href="https://wg21.link/pair.piecewise">[pair.piecewise]</a>), <code>allocator_arg</code> (20.2.7 <a href="https://wg21.link/allocator.tag">[allocator.tag]</a>), 
and <code>adopt_lock</code>/<code>defer_lock</code>/<code>try_to_lock</code> (32.6.5 <a href="https://wg21.link/thread.lock">[thread.lock]</a>) are all required to be 
<code>constexpr</code> with internal linkage. <code>bind()</code>'s placeholders should be allowed to follow this modern practice, 
for increased consistency and reduced implementer headaches (header-only is easier than separately-compiled).
</p>

<p><i>[2015-05-07 Lenexa: Move to Immediate]</i></p>

<p>STL: I'd like this one immediate.</p>
<p>Jonathan: I want to think about forcing constexpr, but the current issue, I have no objections. I'd say ready, but I won't object to immediate if STL wants it.</p>
<p>Marshall: You should report in Kona how it worked out.</p>
<p>STL: We went around a bit on the reflector about how to phrase the encouragement.</p>
<p>Jonathan: I think the shall may be not quite right.</p>
<p>Marshall: I see, you can change your implementation, but you don't.</p>
<p>Jonathan: There's precedent for the shall, but it's wrong, see editorial issue 493.</p>
<p>STL: I would prefer not to ask Daniel to reword, and 493 can fix it later.</p>
<p>Marshall: I remove my objection to immediate because it doesn't force implementations to change.</p>
<p>Marshall: Any other discussion?</p>
<p>Marshall: Immediate vote: 6. Opposed, 0. Abstain, 1.</p>



<p id="res-2488"><b>Proposed resolution:</b></p>
<p>This wording is relative to N4296.</p>

<ol>
<li><p>Change 22.10 <a href="https://wg21.link/function.objects">[function.objects]</a> p2 "Header <code>&lt;functional&gt;</code> synopsis" as depicted:</p>

<blockquote>
<pre>
namespace placeholders {
  <i>// M is the implementation-defined number of placeholders</i>
  <ins><i>see below</i></ins><del>extern <i>unspecified</i></del> _1;
  <ins><i>see below</i></ins><del>extern <i>unspecified</i></del> _2;
  ...
  <ins><i>see below</i></ins><del>extern <i>unspecified</i></del> _M;
}
</pre>
</blockquote>
</li>

<li><p>Change 22.10.15.5 <a href="https://wg21.link/func.bind.place">[func.bind.place]</a> p2 as depicted:</p>

<blockquote>
<pre>
namespace std::placeholders {
  <i>// M is the implementation-defined number of placeholders</i>
  <ins><i>see below</i></ins><del>extern <i>unspecified</i></del> _1;
  <ins><i>see below</i></ins><del>extern <i>unspecified</i></del> _2;
             .
             .
             .
  <ins><i>see below</i></ins><del>extern <i>unspecified</i></del> _M;
}
</pre>
<p>
-1- All placeholder types shall be <code>DefaultConstructible</code> and <code>CopyConstructible</code>, and 
their default constructors and copy/move constructors shall not throw exceptions. It is 
implementation-defined whether placeholder types are <code>CopyAssignable</code>. <code>CopyAssignable</code> 
placeholders' copy assignment operators shall not throw exceptions.
<p/>
<ins>-?- Placeholders should be defined as:</ins>
</p>
<blockquote>
<pre>
<ins>constexpr <i>unspecified</i> _1{};</ins>
</pre>
</blockquote>
<p>
<ins>If they are not, they shall be declared as:</ins>
</p>
<blockquote>
<pre>
<ins>extern <i>unspecified</i> _1;</ins>
</pre>
</blockquote>
</blockquote>
</li>
</ol>






</body>
</html>
