Skip to content

Commit e6e70ed

Browse files
jorisvjcarpent
authored andcommitted
core: fix StdVectorPythonVisitor::expose API
1 parent e1d426e commit e6e70ed

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

include/eigenpy/registration_class.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class registration_class {
3030
return *this;
3131
}
3232

33+
template <class DerivedVisitor>
34+
self& def(bp::def_visitor<DerivedVisitor> const& visitor) {
35+
static_cast<DerivedVisitor const&>(visitor).visit(*this);
36+
return *this;
37+
}
38+
3339
/// \see boost::python::class_::def(char const* name, F f)
3440
template <class F>
3541
self& def(char const* name, F f) {

include/eigenpy/std-vector.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct build_list<vector_type, true> {
6767
}
6868
};
6969

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

421-
template <typename Visitor>
422-
static void expose(const std::string &class_name, const Visitor &visitor) {
421+
template <typename DerivedVisitor>
422+
static void expose(
423+
const std::string &class_name,
424+
const boost::python::def_visitor<DerivedVisitor> &visitor) {
423425
expose(class_name, "", visitor);
424426
}
425427

426-
template <typename Visitor>
427-
static void expose(const std::string &class_name,
428-
const std::string &doc_string, const Visitor &visitor) {
428+
template <typename DerivedVisitor>
429+
static void expose(
430+
const std::string &class_name, const std::string &doc_string,
431+
const boost::python::def_visitor<DerivedVisitor> &visitor) {
429432
// Apply visitor on already registered type or if type is not already
430433
// registered, we define and apply the visitor on it
431434
auto add_std_visitor =

0 commit comments

Comments
 (0)