Boost logo

Boost Users :

From: Zoltan Szatmary (szaki_at_[hidden])
Date: 2005-03-11 07:30:10


Dear Robert

thank you for answering.

> > class A
> > class B : public A
> > class C : public virtual B
> > class D : public virtual B
> > class E : public C, public D
> >
> > so, a classic diamond inheritance which the serialization lib is
> > supposed to be able to tackle with. Now, if I have a piece of code
> > like this
> >
> > boost::serialization::xml_oarchive oa(somestream);
> > A *a = new E();
> > oa << BOOST_SERIALIZATION_NVP(a);
> >
> > it throws exception at the aforementioned line. Examining the template
> > substitutions, template class T is substituted with const B* and
> > template class U is substituted with const A. So, the program should
> > do a downcast on a const A* to const B* which is ought to be possible.
>
> Your example does indicate whether A has any pure virtual functions or not.
> The dynamic down cast will only function if A is polymorphic - that is has
> at least one virtual function. Soooo, I would expect this work if A has at
> least one virtual function and I would expect it to fail if has no virtual
> function. Double check this and get back to us.

Yes, A does have a virtual destructor. But originally A had more virtual member functions, I just trimmed them down when I wanted to locate the source of error.
But yes, class A is still polymorphic. I try to attach the example code to this mail, I hope it will get through.

Best regards

Zoltan




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net