mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 07:02:11 +00:00
enabled casting of const void*
This commit is contained in:
parent
f02f41656b
commit
fd7cf51a56
@ -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
|
||||
|
@ -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<void*>(value), nullptr, destruct), false) {
|
||||
if (!m_ptr) pybind11_fail("Could not allocate capsule object!");
|
||||
}
|
||||
template <typename T> operator T *() const {
|
||||
|
Loading…
Reference in New Issue
Block a user