mirror of
https://github.com/RYDE-WORK/pybind11.git
synced 2026-02-03 14:03:30 +08:00
(perf): use a rvalue cast in func_wrapper (#3966)
* (perf): use an rvalue cast in func_wrapper * Try to clarify comment * Fix comment typo
This commit is contained in:
parent
918d4481a4
commit
c42414db86
@ -98,8 +98,8 @@ public:
|
|||||||
explicit func_wrapper(func_handle &&hf) noexcept : hfunc(std::move(hf)) {}
|
explicit func_wrapper(func_handle &&hf) noexcept : hfunc(std::move(hf)) {}
|
||||||
Return operator()(Args... args) const {
|
Return operator()(Args... args) const {
|
||||||
gil_scoped_acquire acq;
|
gil_scoped_acquire acq;
|
||||||
object retval(hfunc.f(std::forward<Args>(args)...));
|
// casts the returned object as a rvalue to the return type
|
||||||
return retval.template cast<Return>();
|
return object(hfunc.f(std::forward<Args>(args)...)).template cast<Return>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user