Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Polymorphism?
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2008-11-04 20:39:35


  "Robert Dailey" <rcdailey_at_[hidden]> wrote in message news:496954360811041559x67380a74w5526fe1c409cfab6_at_mail.gmail.com...
  Hi,

  I have a class named Bar which derives from a class named Foo. Both Foo and Bar are serializable, and thus they both have the respective serialize() functions. However, if I do the following, you will not get a polymorphic call since you cannot have virtual template members in a class (The serialize() function must be a template according to the Boost.Serialization docs).

  Foo* f = new Bar;
  f->serialize();

  Note that you wouldn't call serialize() directly like this, I'm simply doing it to prove a point. At some point Boost.Serialization is going to want to call the Serialize() function off of my Foo object, however it will not call Bar::serialize() as I would expect since I cannot make serialize() virtual. How would I provide polymorphic serialization of objects in Boost.Serialization?

Doesn't http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/tutorial.html#pointers adequately explain?

Or http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/serialization.html#pointeroperators?

Jeff



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