Replace std::numeric_limits::max with DOLFIN_INVALID_INDEX
Issue #899
new
Rather than using unsigned indices, we should use int32_t
or int64_t
. To smooth the path, I suggest replacing std::numeric_limits::max
where it occurs, with our own symbol, which in future may be -1.
Comments (2)
-
-
I don't like
DOLFIN_INVALID_INDEX
- it hides what's going on. In many places where only positive ints make sense it is better to be explicit with -1. Otherwise one could legitimately use the value thatDOLFIN_INVALID_INDEX
points to and it all gets very confusing. - Log in to comment
I suggest that the transition happens in one of two ways:
Approach A.
introduce
DOLFIN_INVALID_INDEX != std::numeric_limits<T>::max()
for all cases, and raise deprecation warning when user suppliesstd::numeric_limits<T>::max()
.when deprecation period is over, the unsigned type
T
can be switched to anything else.Approach B.
Do the transition in a single step but write careful tests that any reasonable Python representation of
std::numeric_limits<T>::max()
, e.g.numpy.uintp(-1)
, raises an error.If care is not taken, a lot of user code might suffer with spurious/hidden hard to debug problems.