[C++-sig] Wrap a c++ function that returns boost::shared_ptr<> type?

lin yun yunlin07 at gmail.com
Thu Dec 18 07:58:49 CET 2008


> Yes. I believe Py++ deals with boost::shared_ptr without invoking the
> user. Just use default call policy.
That's good news! How about vector<boost::shared_ptr<unsigned short *>> ?

> Can you provide small example of what you are trying to do?

I have a C++ function "imgreader" which reads an image and return a
"unsigned short *" pointer. I have another piece of Python code that calls
imgreader and gets the pointer to the image data. Where should I release the
memory of the image data when it is not needed any more? in python side or
C++ side?

Thanks a lot !

Yun






On Wed, Dec 17, 2008 at 10:41 PM, Roman Yakovenko <roman.yakovenko at gmail.com
> wrote:

> 2008/12/18 lin yun <yunlin07 at gmail.com>:
> > Hi, folks:
> >
> > I am trying to wrap a c++ function that returns a boost::shared_ptr<some
> > class> type using boost.python, is that possible?
>
> Yes. I believe Py++ deals with boost::shared_ptr without invoking the
> user. Just use default call policy.
>
> > BTW, I used the call policy return_range included in Py++ for returning a
> > pointer to a vector. It worked !  My question is that which side is
> > responsible for releasing the memory of the vector, python side or C++
> side?
>
> Can you provide small example of what you are trying to do?
>
> --
> Roman Yakovenko
> C++ Python language binding
> http://www.language-binding.net/
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081217/af7ad77b/attachment-0001.htm>


More information about the Cplusplus-sig mailing list