[C++-sig] [Py++] boost::shared_ptr casting
Roman Yakovenko
roman.yakovenko at gmail.com
Sun Mar 21 17:02:27 CET 2010
On Sun, Mar 21, 2010 at 4:12 PM, peoro <peoro.noob at gmail.com> wrote:
> Ok, it does work as expected if class Base has got at least one virtual member:
>
> from shared_ptr_inheritance import *
> type( base1() ) -> Base
> type( base2() ) -> Derived
> type( derived1() ) -> Derived
> type( base3( derived1() ) ) -> Derived
> type( derived2( base2() ) ) -> Derived
>
> Anyhow it looks like this doesn't depend on py++: py++ always
> generates the same boost::python code no matter of destructor's
> virtuality.
You are right, Py++ assumes that if you have class hierarchy than you
follow simple rules ( at least virtual destructor ).
> ...What if I cannot add a virtual function to the class Base?
As for me, you should not use/expose such code :-) .
More seriously, you will have to show a small and complete example of
what you are trying to expose. In any case, without virtual table you
can't expect the "desired functionality" to work.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
More information about the Cplusplus-sig
mailing list