Skip to content

Commit faf69f8

Browse files
committed
New issue from Hewill: "function_ref should provide result_type"
1 parent 2c9b492 commit faf69f8

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

xml/issue4373.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4373" status="New">
5+
<title>`function_ref` should provide `result_type`</title>
6+
<section>
7+
<sref ref="[func.wrap.ref.class]"/>
8+
</section>
9+
<submitter>Hewill Kang</submitter>
10+
<date>12 Sep 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
Currently, `function`, `move_only_function`, and `copyable_function` all have a
16+
type member `result_type`, but `function_ref` does not:
17+
</p>
18+
<blockquote>
19+
<pre>
20+
static_assert(is_same_v&lt; function &lt;int(int)&gt;::result_type, int&gt;);
21+
static_assert(is_same_v&lt;move_only_function &lt;int(int)&gt;::result_type, int&gt;);
22+
static_assert(is_same_v&lt; copyable_function &lt;int(int)&gt;::result_type, int&gt;);
23+
static_assert(is_same_v&lt; function_ref&lt;int(int)&gt;::result_type, int&gt;); // <span style="color:#C80000;font-weight:bold">error</span>
24+
</pre>
25+
</blockquote>
26+
<p>
27+
It seems worthwhile to also provide it for the latter, as it is consistent with the other
28+
wrappers and allows the user to easily extract the return type.
29+
</p>
30+
</discussion>
31+
32+
<resolution>
33+
<p>
34+
This wording is relative to <paper num="N5014"/>.
35+
</p>
36+
37+
<ol>
38+
39+
<li><p>Modify <sref ref="[func.wrap.ref.class]"/> as indicated:</p>
40+
41+
<blockquote>
42+
<pre>
43+
namespace std {
44+
template&lt;class R, class... ArgTypes&gt;
45+
class function_ref&lt;R(ArgTypes...) <i>cv</i> noexcept(<i>noex</i>)&gt; {
46+
public:
47+
<ins>using result_type = R;</ins>
48+
49+
// <i><sref ref="[func.wrap.ref.ctor]"/>, constructors and assignment operators</i>
50+
template&lt;class F&gt; function_ref(F*) noexcept;
51+
[&hellip;]
52+
};
53+
54+
}
55+
</pre>
56+
</blockquote>
57+
58+
</li>
59+
60+
</ol></resolution>
61+
62+
</issue>

0 commit comments

Comments
 (0)