You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
main: () = {
MIN: u8 = 1;
MAX: u8 = 255;
for MIN..=MAX do (i) {
std::cout << i as u32 << std::endl;
}
}
correctly prints numbers from 1 to 255, while
main: () = {
MIN: u8 = 0;
MAX: u8 = 255;
for MIN..=MAX do (i) {
std::cout << i as u32 << std::endl;
}
}
prints nothing.
(Not discovered by me).
If I have read the implementation right, the boundary conditions are not considered. For example, we have for 0..=UINT32_MAX. And the program will go into an infinite loop or do nothing, because for
range(
T const& f,
T const& l,
bool include_last = false
)
: first{ f }
, last{ l }
{
if (include_last) {
++last;
}
}
curr will never be (or will immediately be) equal to last.
The text was updated successfully, but these errors were encountered:
The fix I decided to use is that if the range type is integral, I widen the stored values so that it's always possible to represent it as a half-open range, which keeps the code simple (or at least simpler, no range/iterator is "simple" exactly 😉 ).
So now the only numeric range I don't support is one whose end value is numeric_limits< [size_t | ptrdiff_t ] >::max(). I think not supporting that case is fine... those are typically used as invalid/sentinel values, not valid program values that you'd want to include in a closed range, I think.
correctly prints numbers from 1 to 255, while
prints nothing.
(Not discovered by me).
The text was updated successfully, but these errors were encountered: