[C++-sig] custom smart pointers

Roman Yakovenko roman.yakovenko at gmail.com
Tue Sep 12 22:55:54 CEST 2006


On 9/12/06, David Abrahams <dave at boost-consulting.com> wrote:
> I made your example work.  I had to add an operator* to your smart
> pointer, although I think that uncovers a bug in Boost.Python: we
> should be using get_pointer where it needed the operator*, instead.
>
> I don't know if this meets your needs or not, but the result is
> enclosed.

Thank you for your time and help.

Unfortunately it did not help :-(.
I reworked the example, base on your comments.

I had to add next conversion:
bp::implicitly_convertible< smart_ptr_t< base_wrapper_t >,
smart_ptr_t< base_i > >();

There are still 2 problems: I am not able to call functions that take
reference and const reference to smart_ptr_t< base > instance.

int ref_get_value( smart_ptr_t<base_i>& a ){
    return a->get_value();
}

I am unable to call this function, I've got ArgumentError exception

int const_ref_get_value( const smart_ptr_t<base_i>& a ){
    return a->get_value();
}

I am unable to call this function, I've got "segmentation fault" on Linux.

I attached test.py file that checks all the functions.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cspc.cpp
Type: text/x-c++src
Size: 5276 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060912/d37f6483/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 1298 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060912/d37f6483/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Jamroot
Type: application/octet-stream
Size: 380 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060912/d37f6483/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: boost-build.jam
Type: application/octet-stream
Size: 283 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060912/d37f6483/attachment-0001.obj>


More information about the Cplusplus-sig mailing list