Skip to content

Commit 5dcea8b

Browse files
committed
New issue from Hewill: "Operators that interact with counted_iterator and default_sentinel_t should be noexcept"
1 parent 25afda1 commit 5dcea8b

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

xml/issue4245.xml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4245" status="New">
5+
<title>Operators that interact with `counted_iterator` and `default_sentinel_t` should be `noexcept`</title>
6+
<section>
7+
<sref ref="[counted.iterator]"/><sref ref="[counted.iter.nav]"/><sref ref="[counted.iter.cmp]"/>
8+
</section>
9+
<submitter>Hewill Kang</submitter>
10+
<date>18 Apr 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
`counted_iterator` can be compared or subtracted from `default_sentinel_t`,
16+
which only involves simple integer arithmetic and does not have any <i>Preconditions</i>.
17+
<p/>
18+
In this case, it is reasonable to declare them as <code>noexcept</code>.
19+
</p>
20+
</discussion>
21+
22+
<resolution>
23+
<p>
24+
This wording is relative to <paper num="N5008"/>.
25+
</p>
26+
27+
<ol>
28+
29+
<li><p>Modify <sref ref="[counted.iterator]"/> as indicated:</p>
30+
31+
<blockquote>
32+
<pre>
33+
namespace std {
34+
template&lt;input_or_output_iterator I&gt;
35+
class counted_iterator {
36+
public:
37+
[&hellip;]
38+
friend constexpr iter_difference_t&lt;I&gt; operator-(
39+
const counted_iterator&amp; x, default_sentinel_t) <ins>noexcept</ins>;
40+
friend constexpr iter_difference_t&lt;I&gt; operator-(
41+
default_sentinel_t, const counted_iterator&amp; y) <ins>noexcept</ins>;
42+
[&hellip;]
43+
friend constexpr bool operator==(
44+
const counted_iterator&amp; x, default_sentinel_t) <ins>noexcept</ins>;
45+
[&hellip;]
46+
};
47+
[&hellip;]
48+
}
49+
</pre>
50+
</blockquote>
51+
52+
</li>
53+
54+
<li><p>Modify <sref ref="[counted.iter.nav]"/> as indicated:</p>
55+
56+
<blockquote>
57+
<pre>
58+
friend constexpr iter_difference_t&lt;I&gt; operator-(
59+
const counted_iterator&amp; x, default_sentinel_t) <ins>noexcept</ins>;
60+
</pre>
61+
<blockquote>
62+
<p>
63+
-15- <i>Effects</i>: Equivalent to: <code>return -x.length;</code>
64+
</p>
65+
</blockquote>
66+
<pre>
67+
friend constexpr iter_difference_t&lt;I&gt; operator-(
68+
default_sentinel_t, const counted_iterator&amp; y) <ins>noexcept</ins>;
69+
</pre>
70+
<blockquote>
71+
<p>
72+
-16- <i>Effects</i>: Equivalent to: <code>return y.length;</code>
73+
</p>
74+
</blockquote>
75+
</blockquote>
76+
77+
</li>
78+
79+
<li><p>Modify <sref ref="[counted.iter.cmp]"/> as indicated:</p>
80+
81+
<blockquote>
82+
<pre>
83+
friend constexpr bool operator==(
84+
const counted_iterator&amp; x, default_sentinel_t) <ins>noexcept</ins>;
85+
</pre>
86+
<blockquote>
87+
<p>
88+
-3- <i>Effects</i>: Equivalent to: <code>return x.length == 0;</code>
89+
</p>
90+
</blockquote>
91+
</blockquote>
92+
93+
</li>
94+
95+
</ol>
96+
</resolution>
97+
98+
</issue>

0 commit comments

Comments
 (0)