From 2d4a20c8cb1009bdc47079581759230a202579e8 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 25 May 2022 12:14:07 -0400 Subject: [PATCH] chore: add missing moves for buffer_func and staticmethod in pybind11.h (#3969) * Use move converting ctor when making class staticmethod * Add missing caster move in buffer func * fix use after move * add back move to staticmethod * avoid shadowing with varname --- include/pybind11/pybind11.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index ca94aaeb..4c392713 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1566,7 +1566,8 @@ public: scope(*this), sibling(getattr(*this, name_, none())), extra...); - attr(cf.name()) = staticmethod(cf); + auto cf_name = cf.name(); + attr(std::move(cf_name)) = staticmethod(std::move(cf)); return *this; } @@ -1620,7 +1621,7 @@ public: if (!caster.load(obj, false)) { return nullptr; } - return new buffer_info(((capture *) ptr)->func(caster)); + return new buffer_info(((capture *) ptr)->func(std::move(caster))); }, ptr); weakref(m_ptr, cpp_function([ptr](handle wr) {