[C++-sig] Re: Call policy with constructor
Mike Rovner
mike at nospam.com
Mon Oct 27 19:11:28 CET 2003
Pierre Barbier de Reuille wrote:
> I want to define a constructor that takes a pointer a keep a reference
> on it. So I need a call policy like 'with_custodian_and_ward<1,2>()'.
>
> But it fails at compile time. Here's me Boost.Python code :
>
> class_<RCPtr<Class> >(name, doc, init<optional<Class*> >())
> .def(init<RCPtr<Class> >())
> .def( init<Class*>(), with_custodian_and_ward<1,2>() )
> ;
You have to use different syntax:
.def( init<Class*>()[with_custodian_and_ward<1,2>()] )
See reference at www.boost.org/libs/python/doc/v2/init.html#init-spec
Mike
More information about the Cplusplus-sig
mailing list