Function lsst::utils::python::cppIndex(std::ptrdiff_t, std::ptrdiff_t)

Function Documentation

std::size_t lsst::utils::python::cppIndex(std::ptrdiff_t size, std::ptrdiff_t i)

Compute a C++ index from a Python index (negative values count from the end) and range-check.

Return

index in the range [0, size - 1]

Note

the size argument has type std::ptrdiff_t instead of std::size_t in order to to match the allowed range for the i argument.

Parameters
  • [in] size: Number of elements in the collection.

  • [in] i: Index into the collection; negative values count from the end

Exceptions
  • Python: IndexError if i not in range [-size, size - 1]