[C++-sig] Re: std::auto_ptr<T> as a return value

David Abrahams dave at boost-consulting.com
Wed Jun 18 21:28:25 CEST 2003

"Jarda Gresula" <jgresula at seznam.cz> writes:

> I don't know if it is actually possible, but if so then could someone
> give an example of how to expose a method returning std::auto_ptr<T>?
> The only way I'm able to achieve it is to write a thin wrapper
> returning T*.

a. Wrap T with auto_ptr<T> as one of the template arguments:

     class_<T, std::auto_ptr<T>, ... >("T")

b. or invoke register_ptr_to_python<std::auto_ptr<T> >();

   (see http://article.gmane.org/gmane.comp.python.c++/2845 for the
   definition of register_ptr_to_python)

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list