[C++-sig] problem returning polymorphic shared_ptr instances

Matt Bendiksen matt_boost at perceptiveautomation.com
Wed Jan 12 21:06:09 CET 2011

Thanks Jim, but I still cannot get it to work. I now have it defined as:

   def("get_a_or_b_instance", get_a_or_b_instance);
   class_<A, boost::shared_ptr<A> >("A", init<>())
   class_<B, boost::shared_ptr<B>, bases<A> >("B", init<>())

(note I change your example line from "bases<B>" to "bases<A>")

I tried it with and without:

   register_ptr_to_python< boost::shared_ptr<B> >();

But from Python whenever I call:


I always get back:

   <class 'app.A'>

Any other ideas?


More information about the Cplusplus-sig mailing list