diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index 0f0adba6..bba99585 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -61,6 +61,9 @@ namespace boost { namespace python { enum no_init_t { no_init }; +template +struct def_arg {}; // Generic visitor + namespace detail { // This function object is used with mpl::for_each to write the id @@ -88,7 +91,7 @@ namespace detail template struct operator_; - + // Register to_python converters for a class T. The first argument // will be mpl::true_ unless noncopyable was specified as a // class_<...> template parameter. The 2nd argument is a pointer to @@ -269,6 +272,14 @@ class class_ : public objects::class_base return *this; } + // Generic visitation + template + self& def(def_arg const& visitor) + { + static_cast(visitor).visit(*this); + return *this; + } + // Wrap a member function or a non-member function which can take // a T, T cv&, or T cv* as its first parameter, or a callable // python object.