[C++-sig] Returning a Python object to C++ (is get_owner the right way?)

Jack Lloyd lloyd at randombit.net
Tue Sep 19 01:51:08 CEST 2006


On Mon, Sep 11, 2006 at 09:53:18PM -0400, David Abrahams wrote:
> Jack Lloyd <lloyd at randombit.net> writes:
> 
> > I have a scenario where I'm wrapping a virtual base class 
> 
> You mean a base class with virtual functions, or an abstract base
> class?  I'm pretty sure you don't mean
> 
>         class a : public virtual b { ... };
> 
> That's a virtual base class.  Pedantry aside...

You are of course correct (virtual bases are involved in this
hierarchy, but what I meant was a class with pure virtual member
functions).

> Not unless you're willing to change the clone member function to
> return shared_ptr<Base> instead of a raw pointer.

That might well be feasible - as it is I'm having to write wrapper
classes all over the place (an exaggeration, 4 or 5 total, as I'm only
exposing objects fairly high up the inheritence tree here), so if I
have to replace my current wrappers with others, that's fine if it
gets me a little closer to easy to read/maintainable code. I'm not too
familiar with Boost's smart pointers, so I'm afraid I'm not
immediately seeing what else I would need to do for this to work. Has
this technique been discussed on the list before?

-Jack



More information about the Cplusplus-sig mailing list