[C++-sig] How to officially wrap a pointer into boost::python::object?
Hans Meine
meine at informatik.uni-hamburg.de
Tue Jun 3 14:21:04 CEST 2008
Am Dienstag, 03. Juni 2008 07:07:19 schrieb Roman Yakovenko:
> > In the end, I would like to know
> > a) what is the right way(tm) for common end users,
> > b) where this is (prominently) documented, and
> > c) what is the perfectly-fine-in-all-cases way for code that should
> > eventually go into the BPL.
>
> std::auto_ptr< Foo > result( new Foo() );
> boost::python::object pyresult( result );
>
> You will have to add somewhere in your registration code next line:
>
> boost::python::register_ptr_to_python< std::auto_ptr< Foo > >();
OK, this is obviously the answer to a), but what about c)?
Background: I want to try to provide a patch for automatic
__copy__/__deepcopy__ support using the code I posted in the past (cf. "How
about class_<...>.enable_copy() ?" thread).
I do not want to register auto_ptr conversions for every class automatically,
or is this considered to be the right way for BPL code?
Interestingly, as I mentioned, manage_new_object eventually uses a
std::auto_ptr holder, too. Obviously, I could go the same route and use
detail::make_owning_holder, but I would still get a PyObject * which I would
need to wrap in a bp::object.
--
Ciao, / /
/--/
/ / ANS
More information about the Cplusplus-sig
mailing list