[C++-sig] [Py++] boost::shared_ptr casting
peoro
peoro.noob at gmail.com
Sun Mar 21 15:12:49 CET 2010
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.
...What if I cannot add a virtual function to the class Base?
On Sun, Mar 21, 2010 at 6:11 AM, Roman Yakovenko
<roman.yakovenko at gmail.com> wrote:
> On Sun, Mar 21, 2010 at 4:07 AM, peoro <peoro.noob at gmail.com> wrote:
>> Yes, having all of the objects at their most-derived type would be
>> what I need, but it's not what happens.
>>
>> I posted a piece of C++ code that shows what I do (I exported it using
>> py++ without any further modification): all of the pointers my
>> functions return are wrapped in boost::shared_ptr's, but from Python I
>> see them at the "derivation level" they were when I passed them to
>> python the first time (look at the summarized output in my previous
>> message)...
>
> Can you check your code, but with the following class definition
>
> class Base {
> public:
> virtual ~Base(){}
> };
>
> class Derived : public Base { };
>
>
> --
> Roman Yakovenko
> C++ Python language binding
> http://www.language-binding.net/
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
More information about the Cplusplus-sig
mailing list