Skip to content

Commit a246a0c

Browse files
committed
New issue from Corentin: "is_within_lifetime should mandate is_object"
1 parent a402779 commit a246a0c

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

xml/issue4138.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4138" status="New">
5+
<title><tt>is_within_lifetime</tt> should mandate <tt>is_object</tt></title>
6+
<section><sref ref="[meta.const.eval]"/></section>
7+
<submitter>Corentin</submitter>
8+
<date>09 Aug 2024</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<blockquote><pre>
13+
int f();
14+
std::is_within_lifetime&lt;int()&gt;(f);
15+
</pre></blockquote>
16+
<p>
17+
This is currently well-formed, and only fails when evaluated because
18+
<tt>is_within_lifetime</tt> is not constrained. However talking of lifetime
19+
of a non-object does not make sense, and the lack of constraint makes the
20+
implementation and use of that function and underlying built-in more
21+
convoluted than necessary.
22+
</p>
23+
</discussion>
24+
25+
<resolution>
26+
<p>
27+
This wording is relative to <paper num="N4988"/>.
28+
</p>
29+
30+
<ol>
31+
32+
<li><p>Modify <sref ref="[meta.type.synop]"/>, header <tt>&lt;type_traits&gt;</tt> synopsis, as indicated:</p>
33+
34+
<blockquote>
35+
<pre>
36+
[&hellip;]
37+
// <i><sref ref="[meta.const.eval]"/>, constant evaluation context</i>
38+
constexpr bool is_constant_evaluated() noexcept;
39+
<ins>template&lt;class T&gt;</ins>
40+
consteval bool is_within_lifetime(const <ins>T</ins><del>auto</del>*) noexcept;
41+
</pre>
42+
</blockquote>
43+
44+
</li>
45+
46+
47+
<li><p>Modify <sref ref="[meta.const.eval]"/> as indicated:</p>
48+
49+
<blockquote>
50+
<pre>
51+
<ins>template&lt;class T&gt;</ins>
52+
consteval bool is_within_lifetime(const <ins>T</ins><del>auto</del>* p) noexcept;
53+
</pre>
54+
<blockquote>
55+
<p>
56+
<ins>-?- <i>Mandates</i>: <tt>is_object_v&lt;T&gt;</tt> is <tt>true</tt>.</ins>
57+
<p/>
58+
-3- <i>Returns</i>: <tt>true</tt> if <tt>p</tt> is a pointer to an object that is
59+
within its lifetime (<sref ref="[basic.life]"/>); otherwise, <tt>false</tt>.
60+
<p/>
61+
-4- <i>Remarks</i>: During the evaluation of an expression <tt>E</tt> as a core
62+
constant expression, a call to this function is ill-formed unless <tt>p</tt>
63+
points to an object that is usable in constant expressions or whose complete
64+
object's lifetime began within <tt>E</tt>.
65+
</p>
66+
</blockquote>
67+
</blockquote>
68+
69+
</li>
70+
71+
</ol>
72+
</resolution>
73+
74+
</issue>

0 commit comments

Comments
 (0)