[C++-sig] smart pointers, polymorphism

Dusty Leary dleary at ttlc.net
Fri Jul 11 07:49:25 CEST 2003


Hello,

Say I have an abstract base class A, an implementation class B, and a
function, void foo(A* a);  If I do a normal boost::python binding, then I
can call foo (from python) with instances of B...  (at least, I think I
can?).

The problem I am having is that we are using boost::intrusive_ptr all over
our project already.  (We could change this perhaps, but that's the way it
is now).  When I expose my classes to boost, it looks like:

class_<A, boost::intrusive_ptr<A> >("A").....;
class_<B, boost::intrusive_ptr<B> >("B").....;

In this case, when I have an python object which wraps an instance of B, I
can't call my foo(A*); function.

How can I make it so that the "polymorphic search" succeeds, in matching
intrusive_ptr<B> against A* parameters?





More information about the Cplusplus-sig mailing list