We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 918d448 commit c42414dCopy full SHA for c42414d
include/pybind11/functional.h
@@ -98,8 +98,8 @@ struct type_caster<std::function<Return(Args...)>> {
98
explicit func_wrapper(func_handle &&hf) noexcept : hfunc(std::move(hf)) {}
99
Return operator()(Args... args) const {
100
gil_scoped_acquire acq;
101
- object retval(hfunc.f(std::forward<Args>(args)...));
102
- return retval.template cast<Return>();
+ // casts the returned object as a rvalue to the return type
+ return object(hfunc.f(std::forward<Args>(args)...)).template cast<Return>();
103
}
104
};
105
0 commit comments