Skip to content

Commit

Permalink
core: fix StdVectorPythonVisitor::expose API
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisv committed Nov 13, 2023
1 parent 2a86f64 commit a78ec39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions include/eigenpy/registration_class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class registration_class {
return *this;
}

template <class DerivedVisitor>
self& def(bp::def_visitor<DerivedVisitor> const& visitor) {
static_cast<DerivedVisitor const&>(visitor).visit(*this);
return *this;
}

/// \see boost::python::class_::def(char const* name, F f)
template <class F>
self& def(char const* name, F f) {
Expand Down
15 changes: 9 additions & 6 deletions include/eigenpy/std-vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct build_list<vector_type, true> {
}
};

/// \brief Change the behaviour of indexing (method __getitem__ in Python).
/// \brief Change the behavior of indexing (method __getitem__ in Python).
/// This is suitable for container of Eigen matrix objects if you want to mutate
/// them.
template <typename Container>
Expand Down Expand Up @@ -418,14 +418,17 @@ struct StdVectorPythonVisitor {
expose(class_name, doc_string, EmptyPythonVisitor());
}

template <typename Visitor>
static void expose(const std::string &class_name, const Visitor &visitor) {
template <typename DerivedVisitor>
static void expose(
const std::string &class_name,
const boost::python::def_visitor<DerivedVisitor> &visitor) {
expose(class_name, "", visitor);
}

template <typename Visitor>
static void expose(const std::string &class_name,
const std::string &doc_string, const Visitor &visitor) {
template <typename DerivedVisitor>
static void expose(
const std::string &class_name, const std::string &doc_string,
const boost::python::def_visitor<DerivedVisitor> &visitor) {
// Apply visitor on already registered type or if type is not already
// registered, we define and apply the visitor on it
auto add_std_visitor =
Expand Down

0 comments on commit a78ec39

Please sign in to comment.