Skip to content

Commit

Permalink
Merge pull request #383 from cmastalli/topic/copyable
Browse files Browse the repository at this point in the history
Extended copyable visitor
  • Loading branch information
jcarpent authored Jul 31, 2023
2 parents ab8c362 + f3edc2e commit 7bddd6a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/eigenpy/copyable.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// Copyright (c) 2016-2021 CNRS INRIA
// Copyright (c) 2016-2023 CNRS INRIA
// Copyright (c) 2023 Heriot-Watt University
//

#ifndef __eigenpy_utils_copyable_hpp__
Expand All @@ -18,10 +19,14 @@ struct CopyableVisitor : public bp::def_visitor<CopyableVisitor<C> > {
template <class PyClass>
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("__deepcopy__", &deepcopy, bp::args("self", "memo"),
"Returns a deep copy of *this.");
}

private:
static C copy(const C& self) { return C(self); }
static C deepcopy(const C& self, bp::dict) { return C(self); }
};
} // namespace eigenpy

Expand Down

0 comments on commit 7bddd6a

Please sign in to comment.