diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 976d28266..613742cf7 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -356,7 +356,8 @@ public: return handle(Py_None).inc_ref(); } - operator void *() { return value; } + template using cast_op_type = void*&; + operator void *&() { return value; } private: void *value = nullptr; };