2
0
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:
Joel de Guzman
2003-07-24 01:44:18 +00:00
parent 42ab6b6b66
commit 3b33f54fb8

View File

@@ -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.