diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index a6f45efc4..aa3001b06 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -197,11 +197,11 @@ public: } operator type*() { return (type *) value; } - operator type&() { return (type &) *value; } + operator type&() { return *((type *) value); } protected: template ::value, int>::type = 0> static void *copy_constructor(const void *arg) { - return new type((const type &)*arg); + return new type(*((const type *)arg)); } template ::value, int>::type = 0> static void *copy_constructor(const void *) { return nullptr; }