Skip to content

Commit c1375f1

Browse files
committed
New issue from Casey: "Some ranges have negative ssize"
1 parent 553b5c9 commit c1375f1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

xml/issue4181.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4181" status="New">
5+
<title>Some ranges have negative `ssize`</title>
6+
<section><sref ref="[iterator.range]"/><sref ref="[range.prim.ssize]"/></section>
7+
<submitter>Casey Carter</submitter>
8+
<date>13 Dec 2024</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
There exist range types `R` whose size is representable by neither `ptrdiff_t` nor
14+
<tt><i>make-signed-like-t</i>&lt;ranges::range_size_t&lt;R&gt;&gt;</tt>, specifically `views::iota(size_t(0), size_t(-1))`.
15+
It's unfortunate that `std::ssize` and `ranges::ssize` produce a negative size for such ranges even when their
16+
difference type is capable of representing their size (see <a href="https://www.godbolt.org/z/599z55Y4f">demo</a>).
17+
Perhaps the `ssize` overloads should return
18+
<tt>static_cast&lt;common_type_t&lt;ptrdiff_t, iter_difference_t&lt;decltype(<i>meow</i>.begin())&gt;&gt;&gt;(<i>meow</i>.size())</tt>
19+
instead when the argument <tt><i>meow</i></tt> models `range`?
20+
</p>
21+
</discussion>
22+
23+
<resolution>
24+
</resolution>
25+
26+
</issue>

0 commit comments

Comments
 (0)