1 #include "pybind11/pybind11.h"
2 #include "pybind11/stl.h"
8 namespace py = pybind11;
9 using namespace pybind11::literals;
16 py::module mod(
"python");
19 mod.def(
"cppIndex", (std::size_t(*)(std::ptrdiff_t, std::ptrdiff_t))
cppIndex,
"size"_a,
"i"_a);
20 mod.def(
"cppIndex", (std::pair<std::size_t, std::size_t>(*)(std::ptrdiff_t, std::ptrdiff_t,
21 std::ptrdiff_t, std::ptrdiff_t))cppIndex,
22 "size_i"_a,
"size_j"_a,
"i"_a,
"j"_a);
PYBIND11_PLUGIN(backtrace)
std::size_t 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.