mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-16 21:57:55 +00:00
enabled casting of const void*
This commit is contained in:
parent
f02f41656b
commit
fd7cf51a56
@ -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 {
|
|||||||
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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user