FWIW Finally had a chance to get back to this and found a way to make it work.

If I remove the implicit conversion from smart_ptr<Factory> to smart_ptr<Factory_wrapper> in the base class export all is good.

Not sure why that leads to the loop and seg fault if you derive from BasicFactory in python though.


On 8/19/05, Scott McKay <skottmckay@gmail.com> wrote:

That has led me to a question on what is required in terms of implicit
conversion calls to handle classes in the same hierarchy that are
wrapped with wrapper<> and held by smart pointers. I can't seem to
find a combination to allow derivation from both Factory and
BasicFactory.

void Export_Factory()
{
    class_< Factory_Wrapper, smart_ptr< Factory_Wrapper > >("Factory",
init<  >())
        .def("generate", &Factory::generate,
&Factory_Wrapper::default_generate, return_self<>())
        .def(init< const Factory& >())
    ;

    implicitly_convertible< smart_ptr< Factory_Wrapper >, smart_ptr<
Factory > >();
    implicitly_convertible< smart_ptr< Factory >, smart_ptr<
Factory_Wrapper > >();
}



void Export_BasicFactory()
{
    class_< BasicFactory_Wrapper, bases< Factory > , smart_ptr<
BasicFactory_Wrapper > >("BasicFactory", init<  >())
        .def("generate", (Factory& (BasicFactory::*)(SourceGroup&)
)&BasicFactory::generate, (Factory&
(BasicFactory_Wrapper::*)(SourceGroup&))&BasicFactory_Wrapper::default_generate,
return_self<>())
        .def(init< const BasicFactory& >())
    ;

    implicitly_convertible< smart_ptr< BasicFactory_Wrapper >,
smart_ptr< Factory > >();
    implicitly_convertible< smart_ptr< Factory >, smart_ptr<
BasicFactory_Wrapper > >();
}