diff --git a/include/pybind11/internal/types.h b/include/pybind11/internal/types.h index c59728ca..d2997b34 100644 --- a/include/pybind11/internal/types.h +++ b/include/pybind11/internal/types.h @@ -53,7 +53,7 @@ public: static type of() { return type_visitor::type(); } - + static type of(const handle& obj) { return type(vm->_t(obj.ptr())); } }; @@ -368,6 +368,10 @@ public: template capsule(T&& value) : object(create(std::forward(value))) {} + capsule(void* ptr, void (*destructor)(void*) = nullptr) : object(create(ptr, destructor)) {} + + void* data() const { return self().ptr; } + template T& cast() const { return *static_cast(self().ptr);