Store a static type_caster rather than the basic type
diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h
index 61eec60..a711752 100644
--- a/include/pybind11/pybind11.h
+++ b/include/pybind11/pybind11.h
@@ -1486,10 +1486,10 @@
pybind11::gil_scoped_acquire gil; \
pybind11::function overload = pybind11::get_overload(static_cast<const cname *>(this), name); \
if (overload) { \
- pybind11::object o = overload(__VA_ARGS__); \
+ auto o = overload(__VA_ARGS__); \
if (pybind11::detail::cast_is_temporary_value_reference<ret_type>::value) { \
- static pybind11::detail::overload_local_t<ret_type> local_value; \
- return pybind11::detail::cast_ref<ret_type>(std::move(o), local_value); \
+ static pybind11::detail::overload_caster_t<ret_type> caster; \
+ return pybind11::detail::cast_ref<ret_type>(std::move(o), caster); \
} \
else return pybind11::detail::cast_safe<ret_type>(std::move(o)); \
} \