From fd7cf51a563cd8e248dc613d22097858bab6c9c1 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 30 Apr 2016 19:13:18 +0200 Subject: [PATCH] enabled casting of const void* --- include/pybind11/cast.h | 2 +- include/pybind11/pytypes.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index f7ba896b7..5ee55c118 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -389,7 +389,7 @@ public: return true; } - static handle cast(void *ptr, return_value_policy /* policy */, handle /* parent */) { + static handle cast(const void *ptr, return_value_policy /* policy */, handle /* parent */) { if (ptr) return capsule(ptr).release(); else diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index a300dd5d1..c9eaa40ec 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -451,8 +451,8 @@ class capsule : public object { public: PYBIND11_OBJECT_DEFAULT(capsule, object, PyCapsule_CheckExact) capsule(PyObject *obj, bool borrowed) : object(obj, borrowed) { } - capsule(void *value, void (*destruct)(PyObject *) = nullptr) - : object(PyCapsule_New(value, nullptr, destruct), false) { + capsule(const void *value, void (*destruct)(PyObject *) = nullptr) + : object(PyCapsule_New(const_cast(value), nullptr, destruct), false) { if (!m_ptr) pybind11_fail("Could not allocate capsule object!"); } template operator T *() const {