enabled casting of const void*

This commit is contained in:
Wenzel Jakob 2016-04-30 19:13:18 +02:00
parent f02f41656b
commit fd7cf51a56
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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 {