<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 4306: Interaction between LWG 2259 and Constraints of member functions</title>
<meta property="og:title" content="Issue 4306: Interaction between LWG 2259 and Constraints of member functions">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4306.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#New">New</a> status.</em></p>
<h3 id="4306"><a href="lwg-active.html#4306">4306</a>. Interaction between LWG 2259 and <i>Constraints</i> of member functions</h3>
<p><b>Section:</b> 16.4.6.5 <a href="https://wg21.link/member.functions">[member.functions]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2025-07-24 <b>Last modified:</b> 2025-08-29</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#member.functions">active issues</a> in [member.functions].</p>
<p><b>View all other</b> <a href="lwg-index.html#member.functions">issues</a> in [member.functions].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
16.4.6.5 <a href="https://wg21.link/member.functions">[member.functions]</a>/2 seems to allow that even when the constraints are not met, 
such a default constructor can be selected, because no restriction is imposed when no overload 
is originally selected. Per the discussion in LWG <a href="lwg-closed.html#2563" title="LWG 2259 relaxes requirements, perhaps unintentionally (Status: NAD)">2563</a><sup><a href="https://cplusplus.github.io/LWG/issue2563" title="Latest snapshot">(i)</a></sup> (closed as NAD), it even 
seems to allow the implementation to add a default constructor when there's originally none.
<p/>
However, we're constraining some member functions, e.g. default constructors of <code class='backtick'>unique_ptr</code>, 
<code class='backtick'>tuple</code>, and <code class='backtick'>variant</code>. Allowance of more permissive overload sets of constructors effectively 
renders the <i>Constraints</i> meaningless, because even if the implementation doesn't constrain 
the default constructors at all, it can still satisfy the restriction in 
16.4.6.5 <a href="https://wg21.link/member.functions">[member.functions]</a>/2 since LWG <a href="lwg-defects.html#2259" title="Issues in 17.6.5.5 rules for member functions (Status: C++17)">2259</a><sup><a href="https://cplusplus.github.io/LWG/issue2259" title="Latest snapshot">(i)</a></sup>.
<p/>
Consider the following example:
</p>
<blockquote><pre>
struct S 
{
  S() = delete;
};

static_assert(std::is_default_constructible_v&lt;std::tuple&lt;S&gt;&gt;);
std::tuple&lt;S&gt; t;
</pre></blockquote>
<p>
Even though currently the default constructor of <code class='backtick'>std::tuple</code> is constrained (22.4.4.2 <a href="https://wg21.link/tuple.cnstr">[tuple.cnstr]</a>/6), 
16.4.6.5 <a href="https://wg21.link/member.functions">[member.functions]</a>/2 seemingly allows the implementation to add another overload that's also 
a default constructor, constrained by "<code>is_default_constructible_v&lt;T<sub><i>i</i></sub>&gt;</code> is <code class='backtick'>false</code> 
for at least one <code><i>i</i></code>", and then render the example well-formed or only error on actual 
instantiation of the "additional" default constructor. Note that such an additional overload effectively 
removes the <i>Constraints</i> element requirements.
<p/>
As shown by the example, the allowance in 16.4.6.5 <a href="https://wg21.link/member.functions">[member.functions]</a>/2 can weaken or even invalidate 
<i>Constraints</i> of member functions.
<p/>
So perhaps some wording change is necessary to guarantee the <i>Constraints</i> of member functions to be meaningful.
</p>

<p><i>[2025-08-29; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll.
</p>



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





</body>
</html>
