Skip to content

Commit 93cf333

Browse files
author
github-actions
committed
Automatic update from GitHub Actions workflow
1 parent fb55c8e commit 93cf333

22 files changed

+448
-44
lines changed

issue4256.html

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Issue 4256: Incorrect constrains for function_ref constructors from nontype_t</title>
6+
<meta property="og:title" content="Issue 4256: Incorrect constrains for function_ref constructors from nontype_t">
7+
<meta property="og:description" content="C++ library issue. Status: New">
8+
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4256.html">
9+
<meta property="og:type" content="website">
10+
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
11+
<meta property="og:image:alt" content="C++ logo">
12+
<style>
13+
p {text-align:justify}
14+
li {text-align:justify}
15+
pre code.backtick::before { content: "`" }
16+
pre code.backtick::after { content: "`" }
17+
blockquote.note
18+
{
19+
background-color:#E0E0E0;
20+
padding-left: 15px;
21+
padding-right: 15px;
22+
padding-top: 1px;
23+
padding-bottom: 1px;
24+
}
25+
ins {background-color:#A0FFA0}
26+
del {background-color:#FFA0A0}
27+
table.issues-index { border: 1px solid; border-collapse: collapse; }
28+
table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
29+
table.issues-index td { padding: 4px; border: 1px solid; }
30+
table.issues-index td:nth-child(1) { text-align: right; }
31+
table.issues-index td:nth-child(2) { text-align: left; }
32+
table.issues-index td:nth-child(3) { text-align: left; }
33+
table.issues-index td:nth-child(4) { text-align: left; }
34+
table.issues-index td:nth-child(5) { text-align: center; }
35+
table.issues-index td:nth-child(6) { text-align: center; }
36+
table.issues-index td:nth-child(7) { text-align: left; }
37+
table.issues-index td:nth-child(5) span.no-pr { color: red; }
38+
@media (prefers-color-scheme: dark) {
39+
html {
40+
color: #ddd;
41+
background-color: black;
42+
}
43+
ins {
44+
background-color: #225522
45+
}
46+
del {
47+
background-color: #662222
48+
}
49+
a {
50+
color: #6af
51+
}
52+
a:visited {
53+
color: #6af
54+
}
55+
blockquote.note
56+
{
57+
background-color: rgba(255, 255, 255, .10)
58+
}
59+
}
60+
</style>
61+
</head>
62+
<body>
63+
<hr>
64+
<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>
65+
<h3 id="4256"><a href="lwg-active.html#4256">4256</a>. Incorrect constrains for <code>function_ref</code> constructors from <code>nontype_t</code></h3>
66+
<p><b>Section:</b> 22.10.17.6.3 <a href="https://wg21.link/func.wrap.ref.ctor">[func.wrap.ref.ctor]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
67+
<b>Submitter:</b> Tomasz Kami&nacute;ski <b>Opened:</b> 2025-05-14 <b>Last modified:</b> 2025-05-14</p>
68+
<p><b>Priority: </b>Not Prioritized
69+
</p>
70+
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
71+
<p><b>Discussion:</b></p>
72+
<p>
73+
For the following class:
74+
</p>
75+
<pre>
76+
struct M
77+
{
78+
void operator();
79+
};
80+
</pre>
81+
<p>
82+
The constructor of <code>function_ref&lt;void()&gt;</code> from <code>nontype_t</code>
83+
is considered to be valid candidate
84+
(is_constructible_v&lt;function_ref&lt;void()&gt;, nontype_t&lt;M{}&gt;&gt; is <code>true</code>),
85+
despite the fact that the corresponding invocation of template argument object, that is const lvalue,
86+
is ill-formed. As consequence we produce hard error from inside of this constructor.
87+
</p>
88+
89+
<p>
90+
This is caused by the fact that for constructors with non-type <code>auto f</code> parameter,
91+
we are checking if <code><i>is-invocable-using</i>&lt;F&gt;</code> is <code>true</code>,
92+
where <code>F</code> is <code>decltype(f)</code> i.e. <code>M</code> for the example.
93+
We should use <code>const F&amp;</code> or <code>decltype((f))</code>.
94+
</p>
95+
96+
97+
98+
<p id="res-4256"><b>Proposed resolution:</b></p>
99+
<p>
100+
This wording is relative to <a href="https://wg21.link/N5008">N5008</a>.
101+
</p>
102+
<ol>
103+
104+
<li><p>Modify 22.10.17.6.3 <a href="https://wg21.link/func.wrap.ref.ctor">[func.wrap.ref.ctor]</a> as indicated:</p>
105+
106+
<blockquote>
107+
<pre>
108+
template&lt;auto f&gt; constexpr function_ref(nontype_t&lt;f&gt;) noexcept;
109+
</pre>
110+
<blockquote>
111+
<p>-8- Let <code>F</code> be <code>decltype(f)</code>.</p>
112+
<p>-9- <i>Constraints</i>: <code><i>is-invocable-using</i>&lt;<ins>const </ins>F<ins>&amp;</ins>&gt;</code> is <code>true</code>.</p>
113+
[&hellip;]
114+
</blockquote>
115+
116+
<pre>
117+
template&lt;auto f, class U&gt; constexpr function_ref(nontype_t&lt;f&gt;, U&amp;&amp; obj) noexcept;
118+
</pre>
119+
<blockquote>
120+
<p>-12- Let <code>T</code> be <code>remove_reference_t&lt;U&gt;</code> and <code>F</code> be <code>decltype(f)</code>.</p>
121+
<p>-13- <i>Constraints:</i>:</p>
122+
<ul>
123+
<li><p>(13.1) <code>is_rvalue_reference_v&lt;U&amp;&amp;&gt;</code> is false, and</p></li>
124+
<li><p>(13.2) <code><i>is-invocable-using</i>&lt;<ins>const </ins>F<ins>&amp;</ins>, T <i>cv</i>&amp;&gt;</code> is <code>true</code>.</p></li>
125+
</ul>
126+
[&hellip;]
127+
</blockquote>
128+
129+
<pre>
130+
template&lt;auto f, class T&gt; constexpr function_ref(nontype_t&lt;f&gt;, T <i>cv</i>* obj) noexcept;
131+
</pre>
132+
<blockquote>
133+
<p>-17- Let <code>F</code> be <code>decltype(f)</code>.</p>
134+
<p>-16- <i>Constraints</i>: <code><i>is-invocable-using</i>&lt;<ins>const </ins>F<ins>&amp;</ins>, T <i>cv</i>*&gt;</code> is <code>true</code>.</p>
135+
[&hellip;]
136+
</blockquote>
137+
</blockquote>
138+
139+
</li>
140+
</ol>
141+
142+
143+
144+
145+
146+
147+
</body>
148+
</html>

0 commit comments

Comments
 (0)