Commit fd7cf51a by Wenzel Jakob

enabled casting of const void*

parent f02f4165
...@@ -389,7 +389,7 @@ public: ...@@ -389,7 +389,7 @@ public:
return true; 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) if (ptr)
return capsule(ptr).release(); return capsule(ptr).release();
else else
......
...@@ -451,8 +451,8 @@ class capsule : public object { ...@@ -451,8 +451,8 @@ class capsule : public object {
public: public:
PYBIND11_OBJECT_DEFAULT(capsule, object, PyCapsule_CheckExact) PYBIND11_OBJECT_DEFAULT(capsule, object, PyCapsule_CheckExact)
capsule(PyObject *obj, bool borrowed) : object(obj, borrowed) { } capsule(PyObject *obj, bool borrowed) : object(obj, borrowed) { }
capsule(void *value, void (*destruct)(PyObject *) = nullptr) capsule(const void *value, void (*destruct)(PyObject *) = nullptr)
: object(PyCapsule_New(value, nullptr, destruct), false) { : object(PyCapsule_New(const_cast<void*>(value), nullptr, destruct), false) {
if (!m_ptr) pybind11_fail("Could not allocate capsule object!"); if (!m_ptr) pybind11_fail("Could not allocate capsule object!");
} }
template <typename T> operator T *() const { template <typename T> operator T *() const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment