Skip to content
Snippets Groups Projects
Unverified Commit 7bddd6ab authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #383 from cmastalli/topic/copyable

Extended copyable visitor
parents ab8c3629 f3edc2e0
No related branches found
No related tags found
No related merge requests found
Pipeline #29084 passed with warnings
// //
// Copyright (c) 2016-2021 CNRS INRIA // Copyright (c) 2016-2023 CNRS INRIA
// Copyright (c) 2023 Heriot-Watt University
// //
#ifndef __eigenpy_utils_copyable_hpp__ #ifndef __eigenpy_utils_copyable_hpp__
...@@ -18,10 +19,14 @@ struct CopyableVisitor : public bp::def_visitor<CopyableVisitor<C> > { ...@@ -18,10 +19,14 @@ struct CopyableVisitor : public bp::def_visitor<CopyableVisitor<C> > {
template <class PyClass> template <class PyClass>
void visit(PyClass& cl) const { void visit(PyClass& cl) const {
cl.def("copy", &copy, bp::arg("self"), "Returns a copy of *this."); cl.def("copy", &copy, bp::arg("self"), "Returns a copy of *this.");
cl.def("__copy__", &copy, bp::arg("self"), "Returns a copy of *this.");
cl.def("__deepcopy__", &deepcopy, bp::args("self", "memo"),
"Returns a deep copy of *this.");
} }
private: private:
static C copy(const C& self) { return C(self); } static C copy(const C& self) { return C(self); }
static C deepcopy(const C& self, bp::dict) { return C(self); }
}; };
} // namespace eigenpy } // namespace eigenpy
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment