os/ossrv/ossrv_pub/boost_apis/boost/python/class.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/class.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,654 @@
     1.4 +// Copyright David Abrahams 2002.
     1.5 +// Distributed under the Boost Software License, Version 1.0. (See
     1.6 +// accompanying file LICENSE_1_0.txt or copy at
     1.7 +// http://www.boost.org/LICENSE_1_0.txt)
     1.8 +#ifndef CLASS_DWA200216_HPP
     1.9 +# define CLASS_DWA200216_HPP
    1.10 +
    1.11 +# include <boost/python/detail/prefix.hpp>
    1.12 +
    1.13 +# include <boost/noncopyable.hpp>
    1.14 +
    1.15 +# include <boost/python/class_fwd.hpp>
    1.16 +# include <boost/python/object/class.hpp>
    1.17 +
    1.18 +# include <boost/python/object.hpp>
    1.19 +# include <boost/python/type_id.hpp>
    1.20 +# include <boost/python/data_members.hpp>
    1.21 +# include <boost/python/make_function.hpp>
    1.22 +# include <boost/python/signature.hpp>
    1.23 +# include <boost/python/init.hpp>
    1.24 +# include <boost/python/args_fwd.hpp>
    1.25 +
    1.26 +# include <boost/python/object/class_metadata.hpp>
    1.27 +# include <boost/python/object/pickle_support.hpp>
    1.28 +# include <boost/python/object/add_to_namespace.hpp>
    1.29 +
    1.30 +# include <boost/python/detail/overloads_fwd.hpp>
    1.31 +# include <boost/python/detail/operator_id.hpp>
    1.32 +# include <boost/python/detail/def_helper.hpp>
    1.33 +# include <boost/python/detail/force_instantiate.hpp>
    1.34 +# include <boost/python/detail/unwrap_type_id.hpp>
    1.35 +# include <boost/python/detail/unwrap_wrapper.hpp>
    1.36 +
    1.37 +# include <boost/type_traits/is_same.hpp>
    1.38 +# include <boost/type_traits/is_member_function_pointer.hpp>
    1.39 +# include <boost/type_traits/is_polymorphic.hpp>
    1.40 +
    1.41 +# include <boost/mpl/size.hpp>
    1.42 +# include <boost/mpl/for_each.hpp>
    1.43 +# include <boost/mpl/bool.hpp>
    1.44 +# include <boost/mpl/not.hpp>
    1.45 +
    1.46 +# include <boost/detail/workaround.hpp>
    1.47 +
    1.48 +# if BOOST_WORKAROUND(__MWERKS__, <= 0x3004)                        \
    1.49 +    /* pro9 reintroduced the bug */                                 \
    1.50 +    || (BOOST_WORKAROUND(__MWERKS__, > 0x3100)                      \
    1.51 +        && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))   \
    1.52 +    || BOOST_WORKAROUND(__GNUC__, < 3)
    1.53 +
    1.54 +#  define BOOST_PYTHON_NO_MEMBER_POINTER_ORDERING 1
    1.55 +
    1.56 +# endif
    1.57 +
    1.58 +# ifdef BOOST_PYTHON_NO_MEMBER_POINTER_ORDERING
    1.59 +#  include <boost/mpl/and.hpp>
    1.60 +#  include <boost/type_traits/is_member_pointer.hpp>
    1.61 +# endif
    1.62 +
    1.63 +namespace boost { namespace python {
    1.64 +
    1.65 +template <class DerivedVisitor> class def_visitor;
    1.66 +
    1.67 +enum no_init_t { no_init };
    1.68 +
    1.69 +namespace detail
    1.70 +{
    1.71 +  // This function object is used with mpl::for_each to write the id
    1.72 +  // of the type a pointer to which is passed as its 2nd compile-time
    1.73 +  // argument. into the iterator pointed to by its runtime argument
    1.74 +  struct write_type_id
    1.75 +  {
    1.76 +      write_type_id(type_info**p) : p(p) {}
    1.77 +
    1.78 +      // Here's the runtime behavior
    1.79 +      template <class T>
    1.80 +      void operator()(T*) const
    1.81 +      {
    1.82 +          *(*p)++ = type_id<T>();
    1.83 +      }
    1.84 +
    1.85 +      type_info** p;
    1.86 +  };
    1.87 +
    1.88 +  template <class T>
    1.89 +  struct is_data_member_pointer
    1.90 +      : mpl::and_<
    1.91 +            is_member_pointer<T>
    1.92 +          , mpl::not_<is_member_function_pointer<T> >
    1.93 +        >
    1.94 +  {};
    1.95 +  
    1.96 +# ifdef BOOST_PYTHON_NO_MEMBER_POINTER_ORDERING
    1.97 +#  define BOOST_PYTHON_DATA_MEMBER_HELPER(D) , detail::is_data_member_pointer<D>()
    1.98 +#  define BOOST_PYTHON_YES_DATA_MEMBER , mpl::true_
    1.99 +#  define BOOST_PYTHON_NO_DATA_MEMBER , mpl::false_
   1.100 +# elif defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
   1.101 +#  define BOOST_PYTHON_DATA_MEMBER_HELPER(D) , 0
   1.102 +#  define BOOST_PYTHON_YES_DATA_MEMBER , int
   1.103 +#  define BOOST_PYTHON_NO_DATA_MEMBER , ...
   1.104 +# else 
   1.105 +#  define BOOST_PYTHON_DATA_MEMBER_HELPER(D)
   1.106 +#  define BOOST_PYTHON_YES_DATA_MEMBER
   1.107 +#  define BOOST_PYTHON_NO_DATA_MEMBER
   1.108 +# endif
   1.109 +  
   1.110 +  namespace error
   1.111 +  {
   1.112 +    //
   1.113 +    // A meta-assertion mechanism which prints nice error messages and
   1.114 +    // backtraces on lots of compilers. Usage:
   1.115 +    //
   1.116 +    //      assertion<C>::failed
   1.117 +    //
   1.118 +    // where C is an MPL metafunction class
   1.119 +    //
   1.120 +    
   1.121 +    template <class C> struct assertion_failed { };
   1.122 +    template <class C> struct assertion_ok { typedef C failed; };
   1.123 +
   1.124 +    template <class C>
   1.125 +    struct assertion
   1.126 +        : mpl::if_<C, assertion_ok<C>, assertion_failed<C> >::type
   1.127 +    {};
   1.128 +
   1.129 +    //
   1.130 +    // Checks for validity of arguments used to define virtual
   1.131 +    // functions with default implementations.
   1.132 +    //
   1.133 +    
   1.134 +    template <class Default>
   1.135 +    void not_a_derived_class_member(Default) {}
   1.136 +    
   1.137 +    template <class T, class Fn>
   1.138 +    struct virtual_function_default
   1.139 +    {
   1.140 +        template <class Default>
   1.141 +        static void
   1.142 +        must_be_derived_class_member(Default const&)
   1.143 +        {
   1.144 +            typedef typename assertion<mpl::not_<is_same<Default,Fn> > >::failed test0;
   1.145 +# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
   1.146 +            typedef typename assertion<is_polymorphic<T> >::failed test1;
   1.147 +# endif 
   1.148 +            typedef typename assertion<is_member_function_pointer<Fn> >::failed test2;
   1.149 +            not_a_derived_class_member<Default>(Fn());
   1.150 +        }
   1.151 +    };
   1.152 +  }
   1.153 +}
   1.154 +
   1.155 +// This is the primary mechanism through which users will expose
   1.156 +// C++ classes to Python.
   1.157 +template <
   1.158 +    class W // class being wrapped
   1.159 +    , class X1 // = detail::not_specified
   1.160 +    , class X2 // = detail::not_specified
   1.161 +    , class X3 // = detail::not_specified
   1.162 +    >
   1.163 +class class_ : public objects::class_base
   1.164 +{
   1.165 + public: // types
   1.166 +    typedef objects::class_base base;
   1.167 +    typedef class_<W,X1,X2,X3> self;
   1.168 +    typedef typename objects::class_metadata<W,X1,X2,X3> metadata;
   1.169 +    typedef W wrapped_type;
   1.170 +    
   1.171 + private: // types
   1.172 +
   1.173 +    // A helper class which will contain an array of id objects to be
   1.174 +    // passed to the base class constructor
   1.175 +    struct id_vector
   1.176 +    {
   1.177 +        typedef typename metadata::bases bases;
   1.178 +        
   1.179 +        id_vector()
   1.180 +        {
   1.181 +            // Stick the derived class id into the first element of the array
   1.182 +            ids[0] = detail::unwrap_type_id((W*)0, (W*)0);
   1.183 +
   1.184 +            // Write the rest of the elements into succeeding positions.
   1.185 +            type_info* p = ids + 1;
   1.186 +            mpl::for_each(detail::write_type_id(&p), (bases*)0, (add_pointer<mpl::_>*)0);
   1.187 +        }
   1.188 +
   1.189 +        BOOST_STATIC_CONSTANT(
   1.190 +            std::size_t, size = mpl::size<bases>::value + 1);
   1.191 +        type_info ids[size];
   1.192 +    };
   1.193 +    friend struct id_vector;
   1.194 +
   1.195 + public: // constructors
   1.196 +    
   1.197 +    // Construct with the class name, with or without docstring, and default __init__() function
   1.198 +    class_(char const* name, char const* doc = 0);
   1.199 +
   1.200 +    // Construct with class name, no docstring, and an uncallable __init__ function
   1.201 +    class_(char const* name, no_init_t);
   1.202 +
   1.203 +    // Construct with class name, docstring, and an uncallable __init__ function
   1.204 +    class_(char const* name, char const* doc, no_init_t);
   1.205 +
   1.206 +    // Construct with class name and init<> function
   1.207 +    template <class DerivedT>
   1.208 +    inline class_(char const* name, init_base<DerivedT> const& i)
   1.209 +        : base(name, id_vector::size, id_vector().ids)
   1.210 +    {
   1.211 +        this->initialize(i);
   1.212 +    }
   1.213 +
   1.214 +    // Construct with class name, docstring and init<> function
   1.215 +    template <class DerivedT>
   1.216 +    inline class_(char const* name, char const* doc, init_base<DerivedT> const& i)
   1.217 +        : base(name, id_vector::size, id_vector().ids, doc)
   1.218 +    {
   1.219 +        this->initialize(i);
   1.220 +    }
   1.221 +
   1.222 + public: // member functions
   1.223 +    
   1.224 +    // Generic visitation
   1.225 +    template <class Derived>
   1.226 +    self& def(def_visitor<Derived> const& visitor)
   1.227 +    {
   1.228 +        visitor.visit(*this);
   1.229 +        return *this;
   1.230 +    }
   1.231 +
   1.232 +    // Wrap a member function or a non-member function which can take
   1.233 +    // a T, T cv&, or T cv* as its first parameter, a callable
   1.234 +    // python object, or a generic visitor.
   1.235 +    template <class F>
   1.236 +    self& def(char const* name, F f)
   1.237 +    {
   1.238 +        this->def_impl(
   1.239 +            detail::unwrap_wrapper((W*)0)
   1.240 +          , name, f, detail::def_helper<char const*>(0), &f);
   1.241 +        return *this;
   1.242 +    }
   1.243 +
   1.244 +    template <class A1, class A2>
   1.245 +    self& def(char const* name, A1 a1, A2 const& a2)
   1.246 +    {
   1.247 +        this->def_maybe_overloads(name, a1, a2, &a2);
   1.248 +        return *this;
   1.249 +    }
   1.250 +
   1.251 +    template <class Fn, class A1, class A2>
   1.252 +    self& def(char const* name, Fn fn, A1 const& a1, A2 const& a2)
   1.253 +    {
   1.254 +        //  The arguments are definitely:
   1.255 +        //      def(name, function, policy, doc_string)
   1.256 +        //      def(name, function, doc_string, policy)
   1.257 +
   1.258 +        this->def_impl(
   1.259 +            detail::unwrap_wrapper((W*)0)
   1.260 +          , name, fn
   1.261 +          , detail::def_helper<A1,A2>(a1,a2)
   1.262 +          , &fn);
   1.263 +
   1.264 +        return *this;
   1.265 +    }
   1.266 +
   1.267 +    template <class Fn, class A1, class A2, class A3>
   1.268 +    self& def(char const* name, Fn fn, A1 const& a1, A2 const& a2, A3 const& a3)
   1.269 +    {
   1.270 +        this->def_impl(
   1.271 +            detail::unwrap_wrapper((W*)0)
   1.272 +          , name, fn
   1.273 +          , detail::def_helper<A1,A2,A3>(a1,a2,a3)
   1.274 +          , &fn);
   1.275 +
   1.276 +        return *this;
   1.277 +    }
   1.278 +
   1.279 +    //
   1.280 +    // Data member access
   1.281 +    //
   1.282 +    template <class D>
   1.283 +    self& def_readonly(char const* name, D const& d, char const* doc=0)
   1.284 +    {
   1.285 +        return this->def_readonly_impl(name, d, doc BOOST_PYTHON_DATA_MEMBER_HELPER(D));
   1.286 +    }
   1.287 +
   1.288 +    template <class D>
   1.289 +    self& def_readwrite(char const* name, D const& d, char const* doc=0)
   1.290 +    {
   1.291 +        return this->def_readwrite_impl(name, d, doc BOOST_PYTHON_DATA_MEMBER_HELPER(D));
   1.292 +    }
   1.293 +    
   1.294 +    template <class D>
   1.295 +    self& def_readonly(char const* name, D& d, char const* doc=0)
   1.296 +    {
   1.297 +        return this->def_readonly_impl(name, d, doc BOOST_PYTHON_DATA_MEMBER_HELPER(D));
   1.298 +    }
   1.299 +
   1.300 +    template <class D>
   1.301 +    self& def_readwrite(char const* name, D& d, char const* doc=0)
   1.302 +    {
   1.303 +        return this->def_readwrite_impl(name, d, doc BOOST_PYTHON_DATA_MEMBER_HELPER(D));
   1.304 +    }
   1.305 +
   1.306 +    // Property creation
   1.307 +# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
   1.308 +    template <class Get>
   1.309 +    self& add_property(char const* name, Get fget, char const* docstr = 0)
   1.310 +    {
   1.311 +        base::add_property(name, this->make_getter(fget), docstr);
   1.312 +        return *this;
   1.313 +    }
   1.314 +
   1.315 +    template <class Get, class Set>
   1.316 +    self& add_property(char const* name, Get fget, Set fset, char const* docstr = 0)
   1.317 +    {
   1.318 +        base::add_property(
   1.319 +            name, this->make_getter(fget), this->make_setter(fset), docstr);
   1.320 +        return *this;
   1.321 +    }
   1.322 +# else
   1.323 + private:
   1.324 +    template <class Get>
   1.325 +    self& add_property_impl(char const* name, Get fget, char const* docstr, int)
   1.326 +    {
   1.327 +        base::add_property(name, this->make_getter(fget), docstr);
   1.328 +        return *this;
   1.329 +    }
   1.330 +
   1.331 +    template <class Get, class Set>
   1.332 +    self& add_property_impl(char const* name, Get fget, Set fset, ...)
   1.333 +    {
   1.334 +        base::add_property(
   1.335 +            name, this->make_getter(fget), this->make_setter(fset), 0);
   1.336 +        return *this;
   1.337 +    }
   1.338 +
   1.339 + public:    
   1.340 +    template <class Get>
   1.341 +    self& add_property(char const* name, Get fget)
   1.342 +    {
   1.343 +        base::add_property(name, this->make_getter(fget), 0);
   1.344 +        return *this;
   1.345 +    }
   1.346 +
   1.347 +    template <class Get, class DocStrOrSet>
   1.348 +    self& add_property(char const* name, Get fget, DocStrOrSet docstr_or_set)
   1.349 +    {
   1.350 +        this->add_property_impl(name, this->make_getter(fget), docstr_or_set, 0);
   1.351 +        return *this;
   1.352 +    }
   1.353 +
   1.354 +    template <class Get, class Set>
   1.355 +    self&
   1.356 +    add_property(char const* name, Get fget, Set fset, char const* docstr)
   1.357 +    {
   1.358 +        base::add_property(
   1.359 +            name, this->make_getter(fget), this->make_setter(fset), docstr);
   1.360 +        return *this;
   1.361 +    }
   1.362 +# endif
   1.363 +        
   1.364 +    template <class Get>
   1.365 +    self& add_static_property(char const* name, Get fget)
   1.366 +    {
   1.367 +        base::add_static_property(name, object(fget));
   1.368 +        return *this;
   1.369 +    }
   1.370 +
   1.371 +    template <class Get, class Set>
   1.372 +    self& add_static_property(char const* name, Get fget, Set fset)
   1.373 +    {
   1.374 +        base::add_static_property(name, object(fget), object(fset));
   1.375 +        return *this;
   1.376 +    }
   1.377 +        
   1.378 +    template <class U>
   1.379 +    self& setattr(char const* name, U const& x)
   1.380 +    {
   1.381 +        this->base::setattr(name, object(x));
   1.382 +        return *this;
   1.383 +    }
   1.384 +
   1.385 +    // Pickle support
   1.386 +    template <typename PickleSuiteType>
   1.387 +    self& def_pickle(PickleSuiteType const& x)
   1.388 +    {
   1.389 +      error_messages::must_be_derived_from_pickle_suite(x);
   1.390 +      detail::pickle_suite_finalize<PickleSuiteType>::register_(
   1.391 +        *this,
   1.392 +        &PickleSuiteType::getinitargs,
   1.393 +        &PickleSuiteType::getstate,
   1.394 +        &PickleSuiteType::setstate,
   1.395 +        PickleSuiteType::getstate_manages_dict());
   1.396 +      return *this;
   1.397 +    }
   1.398 +
   1.399 +    self& enable_pickling()
   1.400 +    {
   1.401 +        this->base::enable_pickling_(false);
   1.402 +        return *this;
   1.403 +    }
   1.404 +
   1.405 +    self& staticmethod(char const* name)
   1.406 +    {
   1.407 +        this->make_method_static(name);
   1.408 +        return *this;
   1.409 +    }
   1.410 + private: // helper functions
   1.411 +
   1.412 +    // Builds a method for this class around the given [member]
   1.413 +    // function pointer or object, appropriately adjusting the type of
   1.414 +    // the first signature argument so that if f is a member of a
   1.415 +    // (possibly not wrapped) base class of T, an lvalue argument of
   1.416 +    // type T will be required.
   1.417 +    //
   1.418 +    // @group PropertyHelpers {
   1.419 +    template <class F>
   1.420 +    object make_getter(F f)
   1.421 +    {
   1.422 +        typedef typename api::is_object_operators<F>::type is_obj_or_proxy;
   1.423 +        
   1.424 +        return this->make_fn_impl(
   1.425 +            detail::unwrap_wrapper((W*)0)
   1.426 +          , f, is_obj_or_proxy(), (char*)0, detail::is_data_member_pointer<F>()
   1.427 +        );
   1.428 +    }
   1.429 +    
   1.430 +    template <class F>
   1.431 +    object make_setter(F f)
   1.432 +    {
   1.433 +        typedef typename api::is_object_operators<F>::type is_obj_or_proxy;
   1.434 +        
   1.435 +        return this->make_fn_impl(
   1.436 +            detail::unwrap_wrapper((W*)0)
   1.437 +          , f, is_obj_or_proxy(), (int*)0, detail::is_data_member_pointer<F>()
   1.438 +        );
   1.439 +    }
   1.440 +    
   1.441 +    template <class T, class F>
   1.442 +    object make_fn_impl(T*, F const& f, mpl::false_, void*, mpl::false_)
   1.443 +    {
   1.444 +        return python::make_function(f, default_call_policies(), detail::get_signature(f, (T*)0));
   1.445 +    }
   1.446 +
   1.447 +    template <class T, class D, class B>
   1.448 +    object make_fn_impl(T*, D B::*pm_, mpl::false_, char*, mpl::true_)
   1.449 +    {
   1.450 +        D T::*pm = pm_;
   1.451 +        return python::make_getter(pm);
   1.452 +    }
   1.453 +
   1.454 +    template <class T, class D, class B>
   1.455 +    object make_fn_impl(T*, D B::*pm_, mpl::false_, int*, mpl::true_)
   1.456 +    {
   1.457 +        D T::*pm = pm_;
   1.458 +        return python::make_setter(pm);
   1.459 +    }
   1.460 +
   1.461 +    template <class T, class F>
   1.462 +    object make_fn_impl(T*, F const& x, mpl::true_, void*, mpl::false_)
   1.463 +    {
   1.464 +        return x;
   1.465 +    }
   1.466 +    // }
   1.467 +    
   1.468 +    template <class D, class B>
   1.469 +    self& def_readonly_impl(
   1.470 +        char const* name, D B::*pm_, char const* doc BOOST_PYTHON_YES_DATA_MEMBER)
   1.471 +    {
   1.472 +        return this->add_property(name, pm_, doc);
   1.473 +    }
   1.474 +
   1.475 +    template <class D, class B>
   1.476 +    self& def_readwrite_impl(
   1.477 +        char const* name, D B::*pm_, char const* doc BOOST_PYTHON_YES_DATA_MEMBER)
   1.478 +    {
   1.479 +        return this->add_property(name, pm_, pm_, doc);
   1.480 +    }
   1.481 +
   1.482 +    template <class D>
   1.483 +    self& def_readonly_impl(
   1.484 +        char const* name, D& d, char const* BOOST_PYTHON_NO_DATA_MEMBER)
   1.485 +    {
   1.486 +        return this->add_static_property(name, python::make_getter(d));
   1.487 +    }
   1.488 +
   1.489 +    template <class D>
   1.490 +    self& def_readwrite_impl(
   1.491 +        char const* name, D& d, char const* BOOST_PYTHON_NO_DATA_MEMBER)
   1.492 +    {
   1.493 +        return this->add_static_property(name, python::make_getter(d), python::make_setter(d));
   1.494 +    }
   1.495 +
   1.496 +    template <class DefVisitor>
   1.497 +    inline void initialize(DefVisitor const& i)
   1.498 +    {
   1.499 +        metadata::register_(); // set up runtime metadata/conversions
   1.500 +        
   1.501 +        typedef typename metadata::holder holder;
   1.502 +        this->set_instance_size( objects::additional_instance_size<holder>::value );
   1.503 +        
   1.504 +        this->def(i);
   1.505 +    }
   1.506 +    
   1.507 +    inline void initialize(no_init_t)
   1.508 +    {
   1.509 +        metadata::register_(); // set up runtime metadata/conversions
   1.510 +        this->def_no_init();
   1.511 +    }
   1.512 +    
   1.513 +    //
   1.514 +    // These two overloads discriminate between def() as applied to a
   1.515 +    // generic visitor and everything else.
   1.516 +    //
   1.517 +    // @group def_impl {
   1.518 +    template <class T, class Helper, class LeafVisitor, class Visitor>
   1.519 +    inline void def_impl(
   1.520 +        T*
   1.521 +      , char const* name
   1.522 +      , LeafVisitor
   1.523 +      , Helper const& helper
   1.524 +      , def_visitor<Visitor> const* v
   1.525 +    )
   1.526 +    {
   1.527 +        v->visit(*this, name,  helper);
   1.528 +    }
   1.529 +
   1.530 +    template <class T, class Fn, class Helper>
   1.531 +    inline void def_impl(
   1.532 +        T*
   1.533 +      , char const* name
   1.534 +      , Fn fn
   1.535 +      , Helper const& helper
   1.536 +      , ...
   1.537 +    )
   1.538 +    {
   1.539 +        objects::add_to_namespace(
   1.540 +            *this
   1.541 +          , name
   1.542 +          , make_function(
   1.543 +                fn
   1.544 +              , helper.policies()
   1.545 +              , helper.keywords()
   1.546 +              , detail::get_signature(fn, (T*)0)
   1.547 +            )
   1.548 +          , helper.doc()
   1.549 +        );
   1.550 +
   1.551 +        this->def_default(name, fn, helper, mpl::bool_<Helper::has_default_implementation>());
   1.552 +    }
   1.553 +    // }
   1.554 +
   1.555 +    //
   1.556 +    // These two overloads handle the definition of default
   1.557 +    // implementation overloads for virtual functions. The second one
   1.558 +    // handles the case where no default implementation was specified.
   1.559 +    //
   1.560 +    // @group def_default {
   1.561 +    template <class Fn, class Helper>
   1.562 +    inline void def_default(
   1.563 +        char const* name
   1.564 +        , Fn
   1.565 +        , Helper const& helper
   1.566 +        , mpl::bool_<true>)
   1.567 +    {
   1.568 +        detail::error::virtual_function_default<W,Fn>::must_be_derived_class_member(
   1.569 +            helper.default_implementation());
   1.570 +            
   1.571 +        objects::add_to_namespace(
   1.572 +            *this, name,
   1.573 +            make_function(
   1.574 +                helper.default_implementation(), helper.policies(), helper.keywords())
   1.575 +            );
   1.576 +    }
   1.577 +    
   1.578 +    template <class Fn, class Helper>
   1.579 +    inline void def_default(char const*, Fn, Helper const&, mpl::bool_<false>)
   1.580 +    { }
   1.581 +    // }
   1.582 +    
   1.583 +    //
   1.584 +    // These two overloads discriminate between def() as applied to
   1.585 +    // regular functions and def() as applied to the result of
   1.586 +    // BOOST_PYTHON_FUNCTION_OVERLOADS(). The final argument is used to
   1.587 +    // discriminate.
   1.588 +    //
   1.589 +    // @group def_maybe_overloads {
   1.590 +    template <class OverloadsT, class SigT>
   1.591 +    void def_maybe_overloads(
   1.592 +        char const* name
   1.593 +        , SigT sig
   1.594 +        , OverloadsT const& overloads
   1.595 +        , detail::overloads_base const*)
   1.596 +
   1.597 +    {
   1.598 +        //  convert sig to a type_list (see detail::get_signature in signature.hpp)
   1.599 +        //  before calling detail::define_with_defaults.
   1.600 +        detail::define_with_defaults(
   1.601 +            name, overloads, *this, detail::get_signature(sig));
   1.602 +    }
   1.603 +
   1.604 +    template <class Fn, class A1>
   1.605 +    void def_maybe_overloads(
   1.606 +        char const* name
   1.607 +        , Fn fn
   1.608 +        , A1 const& a1
   1.609 +        , ...)
   1.610 +    {
   1.611 +        this->def_impl(
   1.612 +            detail::unwrap_wrapper((W*)0)
   1.613 +          , name
   1.614 +          , fn
   1.615 +          , detail::def_helper<A1>(a1)
   1.616 +          , &fn
   1.617 +        );
   1.618 +
   1.619 +    }
   1.620 +    // }
   1.621 +};
   1.622 +
   1.623 +
   1.624 +//
   1.625 +// implementations
   1.626 +//
   1.627 +
   1.628 +template <class W, class X1, class X2, class X3>
   1.629 +inline class_<W,X1,X2,X3>::class_(char const* name, char const* doc)
   1.630 +    : base(name, id_vector::size, id_vector().ids, doc)
   1.631 +{
   1.632 +    this->initialize(init<>());
   1.633 +//  select_holder::assert_default_constructible();
   1.634 +}
   1.635 +
   1.636 +template <class W, class X1, class X2, class X3>
   1.637 +inline class_<W,X1,X2,X3>::class_(char const* name, no_init_t)
   1.638 +    : base(name, id_vector::size, id_vector().ids)
   1.639 +{
   1.640 +    this->initialize(no_init);
   1.641 +}
   1.642 +
   1.643 +template <class W, class X1, class X2, class X3>
   1.644 +inline class_<W,X1,X2,X3>::class_(char const* name, char const* doc, no_init_t)
   1.645 +    : base(name, id_vector::size, id_vector().ids, doc)
   1.646 +{
   1.647 +    this->initialize(no_init);
   1.648 +}
   1.649 +
   1.650 +}} // namespace boost::python
   1.651 +
   1.652 +# undef BOOST_PYTHON_DATA_MEMBER_HELPER
   1.653 +# undef BOOST_PYTHON_YES_DATA_MEMBER
   1.654 +# undef BOOST_PYTHON_NO_DATA_MEMBER
   1.655 +# undef BOOST_PYTHON_NO_MEMBER_POINTER_ORDERING
   1.656 +
   1.657 +#endif // CLASS_DWA200216_HPP