From 50eaa3a746326879f50d26c705528d8bad8845da Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 17 May 2023 16:47:06 -0700 Subject: [PATCH] Add `format_descriptor` Trivial addition, but still in search for a meaningful test. --- include/pybind11/detail/common.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 1ff0df09fe..c2e6f9ec89 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -1025,6 +1025,15 @@ PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used in template struct format_descriptor {}; +template +struct format_descriptor< + T, + detail::enable_if_t::value>> { + static constexpr const char c = 'O'; + static constexpr const char value[2] = {c, '\0'}; + static std::string format() { return std::string(1, c); } +}; + PYBIND11_NAMESPACE_BEGIN(detail) // Returns the index of the given type in the type char array below, and in the list in numpy.h // The order here is: bool; 8 ints ((signed,unsigned)x(8,16,32,64)bits); float,double,long double;