ulti_ww
ulti_ww

Reputation: 1

problems using std::distance function for py::array_t type variable in pybind11

I'd like to get the index of the minimal element of a py::array_t variable in pybind11, but I encountered a problem when trying to combine std::distance and std::min_element.

let's say the py::array_t variable is named arr, the following code will get stuck when it's running:

std::distance(arr.begin(), std::min_element(arr.begin(), arr.end()))

initially I was thinking the py::array_t iterator is not compatible with std::distance function, but I did a test and the following code just works fine:

std::distance(arr.begin(), arr.end())

Can someone explain why the first one does not work? Thanks a lot.

Upvotes: 0

Views: 62

Answers (0)

Related Questions