diff --git a/example/example14.cpp b/example/example14.cpp index 754424e7..13a20ace 100644 --- a/example/example14.cpp +++ b/example/example14.cpp @@ -19,7 +19,7 @@ public: }; /* IMPORTANT: Disable internal pybind11 translation mechanisms for STL data structures */ -PYBIND11_MAKE_OPAQUE(StringList); +PYBIND11_MAKE_OPAQUE(StringList); void init_ex14(py::module &m) { py::class_(m, "StringList") diff --git a/example/example14.py b/example/example14.py index 6bca45b7..1bbe86d8 100644 --- a/example/example14.py +++ b/example/example14.py @@ -8,6 +8,7 @@ from example import ClassWithSTLVecProperty from example import return_void_ptr, print_void_ptr from example import return_null_str, print_null_str from example import return_unique_ptr +from example import Example1 ##### @@ -32,6 +33,7 @@ print_opaque_list(cvp.stringList) ##### print_void_ptr(return_void_ptr()) +print_void_ptr(Example1()) # Should also work for other C++ types print(return_null_str()) print_null_str(return_null_str()) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 5ee55c11..78e50959 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -398,6 +398,7 @@ public: template using cast_op_type = void*&; operator void *&() { return value; } + static PYBIND11_DESCR name() { return _("capsule"); } private: void *value = nullptr; }; diff --git a/include/pybind11/functional.h b/include/pybind11/functional.h index 2d36c5f4..ae3e8b38 100644 --- a/include/pybind11/functional.h +++ b/include/pybind11/functional.h @@ -17,6 +17,7 @@ NAMESPACE_BEGIN(detail) template struct type_caster> { typedef std::function type; + typedef typename std::conditional::value, void_type, Return>::type retval_type; public: bool load(handle src_, bool) { src_ = detail::get_function(src_); @@ -39,7 +40,7 @@ public: PYBIND11_TYPE_CASTER(type, _("function<") + type_caster>::name() + _(" -> ") + - type_caster::type>::name() + + type_caster::name() + _(">")); };