shared_ptr<> w/ Boost::Python
I realize this may not be the right list, but since I'm already subscribed... I've been using boost::python to wrap some C++ code for quite a while now, and I've been quite happy with it. However, I decided to get into boost more, and I've found that shared_ptr/shared_array are quite nice. So I've started changing my functions from returning a raw pointer to returning a shared_ptr. In the boost::python tutorial, they talk about when you return a raw reference or pointer, you need to wrap it to manage lifetime of the object. http://www.boost.org/libs/python/doc/tutorial/doc/call_policies.html In the beginning of that page, they talk about how smart pointers are better for defining the scope and lifetime of objects, but sometimes raw pointers are necessary. I've gotten pretty good about when to manage_new_object, or return_internal_reference, etc. However, now that I have changed my return functions to actually return a smart pointer, it doesn't seem like I should need to wrap the return value anymore. Only now, when I try to do a "get" it gives me the error: " No to_python (by-value) converter found for C++ type: class boost::shared_ptr<class mine> " I have a converter for "class mine". I actually thought that the lifetime managers were using a shared_ptr, so if I did it myself, it would just be transparent. Does anyone know what the proper way to export a shared_ptr into python is? I suppose I could define the shared_ptr<class mine>, and only expose the "get()" function. But that would certainly be less than optimal. (I also obviously cannot wrap my function in another function that returns get(), because that would cause the shared_ptr to have the wrong lifetime.) Thanks for any help, John =:->
John Meinel
I realize this may not be the right list, but since I'm already subscribed...
There's better help to be had on the right list. ;-) -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
David Abrahams
-
John Meinel