Skip to content

Commit 99839bb

Browse files
committed
New issue from Giuseppe D'Angelo: "Missing Mandates: part in optional<T&>::transform"
1 parent 6914fce commit 99839bb

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

xml/issue4299.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4299" status="New">
5+
<title>Missing <i>Mandates:</i> part in <tt>optional&lt;T&amp;&gt;::transform</tt></title>
6+
<section><sref ref="[optional.ref.monadic]"/></section>
7+
<submitter>Giuseppe D'Angelo</submitter>
8+
<date>15 Jul 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
In <sref ref="[optional.ref.monadic]"/> the specification of <tt>optional&lt;T&amp;&gt;::transform</tt>
14+
is missing an additional part of the <i>Mandates:</i> element compared to the primary template's
15+
`transform` (in <sref ref="[optional.monadic]"/> p8; that is, is missing to enforce that
16+
the `U` type is a valid contained type for `optional`.
17+
<p/>
18+
The definition of "valid contained type" comes from <paper num="P2988R12"/>. The paper
19+
amended the <i>Mandates:</i> element of the primary template's `transform` to
20+
use this definition. The fact that the same wording has not been applied to
21+
<tt>optional&lt;T&amp;&gt;::transform</tt> as well looks like an oversight. I would
22+
suggest to apply it.
23+
</p>
24+
</discussion>
25+
26+
<resolution>
27+
<p>
28+
This wording is relative to this
29+
<a href="https://github.com/cplusplus/draft/actions/runs/16433597877/artifacts/3583518547">CD preview draft</a>.
30+
</p>
31+
32+
<ol>
33+
34+
<li><p>Modify <sref ref="[optional.ref.monadic]"/> as indicated:</p>
35+
36+
<blockquote>
37+
<pre>
38+
template&lt;class F&gt;
39+
constexpr optional&lt;remove_cv_t&lt;invoke_result_t&lt;F, T&amp;&gt;&gt;&gt; transform(F&amp;&amp; f) const;
40+
</pre>
41+
<blockquote>
42+
<p>
43+
-4- Let `U` be <tt>remove_cv_t&lt;invoke_result_t&lt;F, T&amp;&gt;&gt;</tt>.
44+
<p/>
45+
-5- <i>Mandates</i>: <ins>`U` is a valid contained type for `optional`.</ins> The declaration
46+
</p>
47+
<blockquote><pre>
48+
U u(invoke(std::forward&lt;F&gt;(f), *val ));
49+
</pre></blockquote>
50+
<p>
51+
is well-formed for some invented variable `u`.
52+
</p>
53+
</blockquote>
54+
</blockquote>
55+
</li>
56+
57+
</ol>
58+
</resolution>
59+
60+
</issue>

0 commit comments

Comments
 (0)