Skip to content

Commit

Permalink
Add format_descriptor<PyObject *>
Browse files Browse the repository at this point in the history
Trivial addition, but still in search for a meaningful test.
  • Loading branch information
rwgk committed May 17, 2023
1 parent 5bea2a8 commit 50eaa3a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,15 @@ PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used in
template <typename T, typename SFINAE = void>
struct format_descriptor {};

template <typename T>
struct format_descriptor<
T,
detail::enable_if_t<detail::is_same_ignoring_cvref<T, PyObject *>::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;
Expand Down

0 comments on commit 50eaa3a

Please sign in to comment.