Add IU64 and Span classes, to compute spans over all integers - #9021
Conversation
| min = 1; | ||
| max = 0; |
There was a problem hiding this comment.
Might as well use min = Max; max = Min to avoid assuming that 0 and 1 can be converted to T.
| static Span<T> empty() { | ||
| Span<T> ret; | ||
| ret.setEmpty(); | ||
| return ret; | ||
| } |
There was a problem hiding this comment.
I would have empty return Span{...} and then have setEmpty() be implemented as *this = empty(), just to make the code more functional (and more consistent with setFull below). It probably doesn't make a difference in practice, though.
| Span<T> ret; | ||
| ret.setFull(); | ||
| return ret; |
There was a problem hiding this comment.
| Span<T> ret; | |
| ret.setFull(); | |
| return ret; | |
| return Span{}; |
| if (isEmpty()) { | ||
| return other.isEmpty(); | ||
| } |
There was a problem hiding this comment.
We could just assume that empty spans have a single canonical representation and skip this check.
There was a problem hiding this comment.
I suppose, though the risk is that someone constructs a non-canonical one manually. I think it's safer as is.
|
Thanks, feedback applied for the first 3 (and replied to the last). |
IU64 is a single numeric representation for both signed and unsigned
integers: it can contain as many negative values as a signed number can,
but also as many unsigned as well (so it needs more than 64 bits).
The Span class is a simple representation of contiguous Spans of numbers.
The next PR will use this internally in the Constraint system, to prove
things.