File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ namespace boost { namespace python {
6161
6262enum no_init_t { no_init };
6363
64+ template <class Derived >
65+ struct def_arg {}; // Generic visitor
66+
6467namespace detail
6568{
6669 // This function object is used with mpl::for_each to write the id
@@ -88,7 +91,7 @@ namespace detail
8891
8992 template <detail::operator_id, class L , class R >
9093 struct operator_ ;
91-
94+
9295 // Register to_python converters for a class T. The first argument
9396 // will be mpl::true_ unless noncopyable was specified as a
9497 // class_<...> template parameter. The 2nd argument is a pointer to
@@ -269,6 +272,14 @@ class class_ : public objects::class_base
269272 return *this ;
270273 }
271274
275+ // Generic visitation
276+ template <class Derived >
277+ self& def (def_arg<Derived> const & visitor)
278+ {
279+ static_cast <Derived const &>(visitor).visit (*this );
280+ return *this ;
281+ }
282+
272283 // Wrap a member function or a non-member function which can take
273284 // a T, T cv&, or T cv* as its first parameter, or a callable
274285 // python object.
You can’t perform that action at this time.
0 commit comments