diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 64e6eeea..a5ee2c5f 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -764,10 +764,11 @@ public: NAMESPACE_END(detail) template inline T cast(handle handle) { - detail::type_caster::type> conv; + typedef detail::type_caster::type> type_caster; + type_caster conv; if (!conv.load(handle, true)) throw cast_error("Unable to cast Python object to C++ type"); - return (T) conv; + return conv.operator typename type_caster::template cast_op_type(); } template inline object cast(const T &value, return_value_policy policy = return_value_policy::automatic_reference, handle parent = handle()) {