[C++-sig] Re: Call policy with constructor
by David Abrahams other posts by this author
Oct 27 2003 11:00AM messages near this date
[C++-sig] Re: fat class decoration
|
[C++-sig] Re: container suite feedback & ideas
"Mike Rovner" <mike@[...].com> writes:
> 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
...and you probably don't want the optional<Class*> in the first
init<...> .
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
|