Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-10-10 14:10:13


Double check that a is polymorphic - that is, that it has at least one
virtual function. Then get back to us.

Robert Ramey

Jared McIntyre wrote:
> I've gone through the documentation, and I'm still unable to get this
> particular aspect of serialization working. I have two objects 'a'
> and 'b', and 'b' inherits from 'a'. I have a vector of 'a' pointers
> that may just be 'a' or may be 'b'. I've preregistered 'b', right
> before the vector serialization occurs, so that the serialization
> system should properly recognize that 'b' inherits from 'a'. However,
> only the 'a' pieces of each 'b' in the vector serializes. If I place
> all the 'b' items in a second 'b' containing vector, and serialize
> that afterwards, it properly discovers that the 'a' part has been
> serialized already and simply points to that reference. I don't
> really want to store this second 'b' vector. Is there a way to get a
> vector of a items to also serialize the 'b' part of the element if
> the item is a 'b'?
>
> I apologize if this is already in the documentation, but if it is, I
> missed it.
>
> Also, there is an issue in the documentation. In the "Pointers to
> Objects of Derived Classes" section, it has example registration code:
>
> main(){
> ...
> ar.template register_type<derived_one>();
> ar.template register_type<derived_two>();
> base *b;
> ar & b;
> }
>
> I'm guessing that is supposed to be:
>
> main(){
> ...
> ar.register_type<derived_one>();
> ar.register_type<derived_two>();
> base *b;
> ar & b;
> }

nope, its correct. This is a little known quirk of C++ syntax. Your second
version won't compile on the most conforming compilers.

Robert Ramey

> Thanks,
>
> Jared
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


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