Skip to content

Commit 7d3afa0

Browse files
committed
New issue from Marek Polacek: "Add consteval to std::meta::exception defaulted member functions"
1 parent e66529d commit 7d3afa0

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

xml/issue4494.xml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4494" status="New">
5+
<title>Add `consteval` to `std::meta::exception` defaulted member functions</title>
6+
<section><sref ref="[meta.reflection.exception]"/></section>
7+
<submitter>Marek Polacek</submitter>
8+
<date>16 Dec 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
<a href="https://wg21.link/cwg3115">CWG 3115</a> states that every function of consteval-only type shall be an
14+
immediate function. This caused a problem for `std::meta::exception::what()` which was marked `constexpr`
15+
but not `consteval`. To be able to mark it `consteval`, we had to tweak the rules about overriding by a consteval
16+
virtual function (<a href="https://wg21.link/cwg3117">CWG 3117</a> ).
17+
<p/>
18+
But <sref ref="[meta.reflection.exception]"/> still defines `std::meta::exception` such that it contains these
19+
defaulted special member functions:
20+
</p>
21+
<blockquote><pre>
22+
exception(const exception&amp;) = default;
23+
exception(exception&amp;&amp;) = default;
24+
25+
exception&amp; operator=(const exception&amp;) = default;
26+
exception&amp; operator=(exception&amp;&amp;) = default;
27+
</pre></blockquote>
28+
<p>
29+
which aren't `consteval` (and since they're not templates, they won't be
30+
promoted to `consteval` as per <paper num="P2564"/>). I propose to make the four functions
31+
`consteval`:
32+
</p>
33+
<blockquote><pre>
34+
<ins>consteval</ins> exception(const exception&amp;) = default;
35+
<ins>consteval</ins> exception(exception&amp;&amp;) = default;
36+
37+
<ins>consteval</ins> exception&amp; operator=(const exception&amp;) = default;
38+
<ins>consteval</ins> exception&amp; operator=(exception&amp;&amp;) = default;
39+
</pre></blockquote>
40+
</discussion>
41+
42+
<resolution>
43+
<p>
44+
This wording is relative to <paper num="N5032"/>.
45+
</p>
46+
47+
<ol>
48+
<li><p>Modify <sref ref="[meta.reflection.exception]"/> as indicated:</p>
49+
50+
<blockquote>
51+
<pre>
52+
namespace std::meta {
53+
class exception : public std::exception {
54+
private:
55+
optional&lt;string&gt; <i>what_</i>; <i>// exposition only</i>
56+
u8string <i>u8what_</i>; <i>// exposition only</i>
57+
info <i>from_</i>; <i>// exposition only</i>
58+
source_location <i>where_</i>; <i>// exposition only</i>
59+
public:
60+
consteval exception(u8string_view what, info from,
61+
source_location where = source_location::current()) noexcept;
62+
63+
consteval exception(string_view what, info from,
64+
source_location where = source_location::current()) noexcept;
65+
66+
<ins>consteval</ins> exception(const exception&amp;) = default;
67+
<ins>consteval</ins> exception(exception&amp;&amp;) = default;
68+
69+
<ins>consteval</ins> exception&amp; operator=(const exception&amp;) = default;
70+
<ins>consteval</ins> exception&amp; operator=(exception&amp;&amp;) = default;
71+
72+
constexpr const char* what() const noexcept override;
73+
consteval u8string_view u8what() const noexcept;
74+
consteval info from() const noexcept;
75+
consteval source_location where() const noexcept;
76+
};
77+
}
78+
</pre>
79+
</blockquote>
80+
</li>
81+
82+
</ol>
83+
84+
</resolution>
85+
86+
</issue>

0 commit comments

Comments
 (0)