[C++-sig] How to manage smart pointer as return value of a factory?

David Abrahams dave at boost-consulting.com
Wed Feb 15 20:43:51 CET 2006


Julien <swell at netcourrier.com> writes:

> Hello, 
>     I use the Boost.Python lib for a couple of weeks now and i am 
> facing a pb. 
> To sum up i have a small hierarchy of objects and have a factory to 
> build concrete object. The pb is i think aroud the auto_ptr object that 
> is not correctly managed by my code ( i use version 1.33 ) 
> I think that the solution is obvious but i can't sort it out. If you 
> could have a look at this small test 


All you should need is

  boost::python::register_ptr_to_python<std::auto_ptr<X> >();

And *nothing* else.

http://www.boost.org/libs/python/doc/v2/register_ptr_to_python.html

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list