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
This commit is contained in:
Aaron Gokaslan 2022-05-25 12:14:07 -04:00 committed by GitHub
parent 4624e8e164
commit 2d4a20c8cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {