diff --git a/python/mujoco/callbacks.cc b/python/mujoco/callbacks.cc index 929e3458..c6a99351 100644 --- a/python/mujoco/callbacks.cc +++ b/python/mujoco/callbacks.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "errors.h" @@ -46,7 +47,7 @@ using enable_if_not_const_t = // table that associates raw MuJoCo struct pointers back to the pointers to // their corresponding wrappers. template -static enable_if_not_const_t MjWrapperLookup(Raw* ptr) { +static enable_if_not_const_t MjWrapperLookup(Raw* ptr) { using LookupFnType = MjWrapper* (Raw*); static LookupFnType* const lookup = []() -> LookupFnType* { py::gil_scoped_acquire gil; @@ -102,7 +103,7 @@ static enable_if_not_const_t MjWrapperLookup(Raw* ptr) { "cannot find the Python instance of the MjWrapper"); } } else { - return instance; + return std::move(instance); } } else { if (!PyErr_Occurred()) { @@ -117,7 +118,7 @@ static enable_if_not_const_t MjWrapperLookup(Raw* ptr) { } template -static const py::object MjWrapperLookup(const Raw* ptr) { +static const py::handle MjWrapperLookup(const Raw* ptr) { return MjWrapperLookup(const_cast(ptr)); }