Skip to content

Commit 50eaa3a

Browse files
committed
Add format_descriptor<PyObject *>
Trivial addition, but still in search for a meaningful test.
1 parent 5bea2a8 commit 50eaa3a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/pybind11/detail/common.h

+9
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,15 @@ PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used in
10251025
template <typename T, typename SFINAE = void>
10261026
struct format_descriptor {};
10271027

1028+
template <typename T>
1029+
struct format_descriptor<
1030+
T,
1031+
detail::enable_if_t<detail::is_same_ignoring_cvref<T, PyObject *>::value>> {
1032+
static constexpr const char c = 'O';
1033+
static constexpr const char value[2] = {c, '\0'};
1034+
static std::string format() { return std::string(1, c); }
1035+
};
1036+
10281037
PYBIND11_NAMESPACE_BEGIN(detail)
10291038
// Returns the index of the given type in the type char array below, and in the list in numpy.h
10301039
// The order here is: bool; 8 ints ((signed,unsigned)x(8,16,32,64)bits); float,double,long double;

0 commit comments

Comments
 (0)