Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-11 08:51:10


From: "Peter Dimov" <pdimov_at_[hidden]>
> From: "Vladimir Prus" <ghost_at_[hidden]>
> > Peter Dimov wrote:
> > > Not only that, but you also need to register derived to base
> conversions,
> > > too, as I recently realized, since Derived * -> void * -> Base * is
not
> > > required to work.
> >
> > Why do you need such a conversion?
>
> Because when you are reading a polymorphic object via a pointer to Base,
you
> don't have Derived available at compile time; you only have a string that
> identifies that Derived. You can dispatch on that string and get back a
> void* to the object; now you must convert that void* to a Base*.

This can be avoided by requiring all serializable polymorphic objects to
derive from a known polymorphic type that can be used as a "carrier" instead
of void*; then dynamic_cast<Base*> will work.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk