held type and implicitly_convertible

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

held type and implicitly_convertible

Wojciech Mamrak
Hello list,

correct me if I am wrong, but based on what I have found in the docs,
SO and few other places, when creating an object in Python and passing
it to a wrapped C++ function which expects a pointer and which takes
the ownership of that pointer, one should:
* use auto_ptr as held type when wrapping types being passed to that function,
* create a wrapper function expecting auto_ptr which calls original
function and releases the auto_ptr.

Additionally, if polymorphic types are to be passed, then
implicitly_convertible should be used to avoid writing multiple
wrapper functions for each derived type.

My question is: what happens if held type of my class is auto_ptr<T>,
and the (original) function expects boost::shared_ptr<T>?
Does BP register a converter for these types automatically, since
implicitly_convertible is not needed at all this time?
Does it call shared_ptr's ctor with auto_ptr as its parameter (which
calls auto_ptr's release method, causing a wrapper function to be
Or maybe such mixing of smart pointers should be completely avoided?

Thanks for help,
Cplusplus-sig mailing list
[hidden email]