mirror of
https://github.com/boostorg/python.git
synced 2026-01-26 06:42:27 +00:00
Added generic visitation mechanism.
[SVN r19288]
This commit is contained in:
@@ -61,6 +61,9 @@ namespace boost { namespace python {
|
||||
|
||||
enum no_init_t { no_init };
|
||||
|
||||
template <class Derived>
|
||||
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 <detail::operator_id, class L, class R>
|
||||
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 <class Derived>
|
||||
self& def(def_arg<Derived> const& visitor)
|
||||
{
|
||||
static_cast<Derived const&>(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.
|
||||
|
||||
Reference in New Issue
Block a user