File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed
test/std/ranges/range.factories/range.iota.view Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -363,15 +363,14 @@ namespace ranges {
363
363
(integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
364
364
{
365
365
if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) {
366
- if (__value_ < 0 ) {
367
- if ( __bound_sentinel_ < 0 ) {
368
- return std::__to_unsigned_like (-__value_) - std::__to_unsigned_like (-__bound_sentinel_);
369
- }
370
- return std::__to_unsigned_like (__bound_sentinel_) + std::__to_unsigned_like (- __value_);
371
- }
372
- return std::__to_unsigned_like (__bound_sentinel_) - std::__to_unsigned_like ( __value_);
366
+ return (__value_ < 0 )
367
+ ? (( __bound_sentinel_ < 0 )
368
+ ? std::__to_unsigned_like (-__value_) - std::__to_unsigned_like (-__bound_sentinel_)
369
+ : std::__to_unsigned_like (__bound_sentinel_) + std::__to_unsigned_like (-__value_))
370
+ : std::__to_unsigned_like (__bound_sentinel_) - std::__to_unsigned_like (__value_);
371
+ } else {
372
+ return std::__to_unsigned_like (__bound_sentinel_ - __value_);
373
373
}
374
- return std::__to_unsigned_like (__bound_sentinel_ - __value_);
375
374
}
376
375
};
377
376
Original file line number Diff line number Diff line change 10
10
11
11
// constexpr auto size() const requires see below;
12
12
13
- #include < ranges>
14
13
#include < cassert>
14
+ #include < concepts>
15
15
#include < limits>
16
+ #include < ranges>
16
17
17
18
#include " test_macros.h"
18
19
#include " types.h"
@@ -89,6 +90,15 @@ constexpr bool test() {
89
90
assert (io.size () == 0 );
90
91
}
91
92
93
+ // Make sure iota_view<short, short> works properly. For details,
94
+ // see https://github.com/llvm/llvm-project/issues/67551.
95
+ {
96
+ static_assert (std::ranges::sized_range<std::ranges::iota_view<short , short >>);
97
+ std::ranges::iota_view<short , short > io (10 , 20 );
98
+ std::same_as<unsigned int > auto sz = io.size ();
99
+ assert (sz == 10 );
100
+ }
101
+
92
102
return true ;
93
103
}
94
104
You can’t perform that action at this time.
0 commit comments