[C++-sig] can these exports be avoided

Gennadiy Rozental rogeeff at gmail.com
Mon Nov 10 21:20:19 CET 2008


Hans Meine <meine <at> informatik.uni-hamburg.de> writes:

> 
> On Monday 10 November 2008 08:56:14 Gennadiy Rozental wrote:
> > It can be resolved with additional export for class Derived:
> >
> > bp::class_<Derived,bp::bases<Base>,noncopyable>
> >   ( "Derived", bp::no_init );
> >
> > In which case above print statement starts 
> > to show mymodule.Derived.
> 
> AFAICS that's the proper solution.

My current workaround looks like this:

Base*
as_base( IObject* obj )
{
    return dynamic_cast<Base*>( obj );
}

Next I export this  function and use if in Python in all 
point of foo() invocation:

 mymodule.as_base( object_derived_from_base ).foo()

Gennadiy



More information about the Cplusplus-sig mailing list