Skip to content

Commit a91fd2a

Browse files
committed
New issue from Jiang An: "Interaction between LWG 2259 and Constraints of member functions"
1 parent 647969b commit a91fd2a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

xml/issue4306.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4306" status="New">
5+
<title>Interaction between LWG 2259 and <i>Constraints</i> of member functions</title>
6+
<section><sref ref="[member.functions]"/></section>
7+
<submitter>Jiang An</submitter>
8+
<date>24 Jul 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
<sref ref="[member.functions]"/>/2 seems to allow that even when the constraints are not met,
14+
such a default constructor can be selected, because no restriction is imposed when no overload
15+
is originally selected. Per the discussion in LWG <iref ref="2563"/> (closed as NAD), it even
16+
seems to allow the implementation to add a default constructor when there's originally none.
17+
<p/>
18+
However, we're constraining some member functions, e.g. default constructors of `unique_ptr`,
19+
`tuple`, and `variant`. Allowance of more permissive overload sets of constructors effectively
20+
renders the <i>Constraints</i> meaningless, because even if the implementation doesn't constrain
21+
the default constructors at all, it can still satisfy the restriction in
22+
<sref ref="[member.functions]"/>/2 since LWG <iref ref="2259"/>.
23+
<p/>
24+
Consider the following example:
25+
</p>
26+
<blockquote><pre>
27+
struct S
28+
{
29+
S() = delete;
30+
};
31+
32+
static_assert(std::is_default_constructible_v&lt;std::tuple&lt;S&gt;&gt;);
33+
std::tuple&lt;S&gt; t;
34+
</pre></blockquote>
35+
<p>
36+
Even though currently the default constructor of `std::tuple` is constrained (<sref ref="[tuple.cnstr]"/>/6),
37+
<sref ref="[member.functions]"/>/2 seemingly allows the implementation to add another overload that's also
38+
a default constructor, constrained by "<tt>is_default_constructible_v&lt;T<sub><i>i</i></sub>&gt;</tt> is `false`
39+
for at least one <tt><i>i</i></tt>", and then render the example well-formed or only error on actual
40+
instantiation of the "additional" default constructor. Note that such an additional overload effectively
41+
removes the <i>Constraints</i> element requirements.
42+
<p/>
43+
As shown by the example, the allowance in <sref ref="[member.functions]"/>/2 can weaken or even invalidate
44+
<i>Constraints</i> of member functions.
45+
<p/>
46+
So perhaps some wording change is necessary to guarantee the <i>Constraints</i> of member functions to be meaningful.
47+
</p>
48+
</discussion>
49+
50+
<resolution>
51+
</resolution>
52+
53+
</issue>

0 commit comments

Comments
 (0)