diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index b7e346ef30..228e02c3d8 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -1428,25 +1428,11 @@ struct npy_format_descriptor< }; template -struct npy_format_descriptor::value>> { - static constexpr auto name = const_name("object"); - - static constexpr int value = npy_api::NPY_OBJECT_; - - static pybind11::dtype dtype() { return pybind11::dtype(/*typenum*/ value); } -}; - -template <> -struct npy_format_descriptor> { - static constexpr auto name = const_name("object"); - - static constexpr int value = npy_api::NPY_OBJECT_; - - static pybind11::dtype dtype() { return pybind11::dtype(/*typenum*/ value); } -}; - -template <> -struct npy_format_descriptor> { +struct npy_format_descriptor< + T, + enable_if_t::value + || ((std::is_same::value || std::is_same::value) + && sizeof(T) == sizeof(PyObject *))>> { static constexpr auto name = const_name("object"); static constexpr int value = npy_api::NPY_OBJECT_;