[C++-sig] held type and implicitly_convertible

Wojciech Mamrak wmamrak at gmail.com
Mon Apr 30 13:05:50 CEST 2012


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
unneeded)?
Or maybe such mixing of smart pointers should be completely avoided?


Thanks for help,
regards


More information about the Cplusplus-sig mailing list