Replace std::numeric_limits::max with DOLFIN_INVALID_INDEX

Issue #899 new
Chris Richardson created an issue

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)

  1. Jan Blechta

    I suggest that the transition happens in one of two ways:

    Approach A.

    1. introduce DOLFIN_INVALID_INDEX != std::numeric_limits<T>::max() for all cases, and raise deprecation warning when user supplies std::numeric_limits<T>::max().

    2. 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.

  2. Prof Garth Wells

    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 that DOLFIN_INVALID_INDEX points to and it all gets very confusing.

  3. Log in to comment