我正在尝试使用 pybind11 从 c++ 修改一个 numpy 字符串数组。我正在使用的代码具有以下结构:
py::array_t<py::str> process_array(py::array_t<py::str> input);
PYBIND11_EMBEDDED_MODULE(fast_calc, m) {
m.def("process_array", process_array);
}
py::array_t<py::str> process_array(py::array_t<py::str> input) {
auto buf = input.request();
cout << &buf;
return input;
}
我面临的问题是此错误消息:
pybind11/numpy.h:1114:19:错误:静态断言失败:尝试使用非 POD 或未实现的 POD 类型作为 numpy dtype static_assert(is_pod_struct::value, "尝试使用非 POD 或未实现的 POD 类型作为一个 numpy dtype");
不知道有什么问题。在 python 中,您可以创建 numpy 字符串数组,那么我做错了什么?谢谢。