Boost logo

Boost Users :

Subject: Re: [Boost-users] [repost][serialization] version handling in{save|load}_construct_data
From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2010-01-10 06:25:51


________________________________________
De: boost-users-bounces_at_[hidden] [boost-users-bounces_at_[hidden]] En nombre de Robert Ramey [ramey_at_[hidden]]
Enviado el: sábado, 09 de enero de 2010 21:40
Para: boost-users_at_[hidden]
Asunto: Re: [Boost-users] [repost][serialization] version handling in{save|load}_construct_data

> I believe that this came about when error to the serialization of
> collections was discovered. Previous library versions didn't
> properly save the version of the collection item. When this
> was corrected, this code was needed to permit the the loading
> of archives created previously.
>
> If the type isn't versioned (e.g. some primitive type), then the
> default version # would be zero. I suppose this could be
> made more elaborate so that the version # wouldn't even
> be in the archive in these cases - but that's not way we did it.
>
> I don't know if that answers your question, but that's what
> I remember about it.

I'm afraid that does not entirely answer my question. I understand
what the "if(3 < ar.get_library_version()){" guard is for. What
puzzles is me is why you need to explicitly save the type
serialization version number when this info is seemingly recovered in
other contexts without any explicit user operation. Let me put it
another way: consider a user defined type my_type with associated
serialization code:

  template<class Archive>
  void serialize(Archive& ar,my_type & m,const unsigned int version)
  {
    ...
  }

When serialize() is called internally by Boost.Serialization, version is
correctly passed without the user explicitly saving this info as it
happens in the code for collection serialization. Why this difference?
Am i making myself clear as to what the root of my puzzlement
is?

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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