On Sunday, March 11, 2018, james <dirtydroog@gmail.com> wrote:


On Sunday, March 11, 2018, Lars Ruoff via Boost-users <boost-users@lists.boost.org> wrote:
Hi,
i use the class versioning feature of Boost.Serialization, with an external (non-intrusive) serialization function like this:

BOOST_CLASS_VERSION(GAMEINFO, 1)

template <typename Archive>
void serialize(Archive &ar, GAMEINFO& gameSettings, const unsigned int version)
{
ar & gameSettings.NPODS;
// ...
if (version > 0)
ar & gameSettings.ARENA_GOAL_EXCLUSION_RADIUS;
}

Now as soon, as i set BOOST_CLASS_VERSION(GAMEINFO, 1), i get version==1 in this serialize function, even when i *deserialize* (load from archive).
I would have expected to get the version of the data in the saved archive in this case.

Say i saved with an old version=0.
Then my class evolved and i set BOOST_CLASS_VERSION(GAMEINFO, 1).
But when reading the old archive, i expect version==0 in the function so i can react on it.
Instead, i get always version==1, as soon as i compile with BOOST_CLASS_VERSION(GAMEINFO, 1), even when i'm reading old files!
What am i missing?

regards,
Lars R.



You're not missing anything based on my similar experience. We ended up not using the version functionality because it turned out to be useless. It made rolling out code changes a tedious affair, which if not choreographed carefully would lead to deserialisation changes in the best case, and crashes in the worst. We plan to drop boost serialisation entirely.

Maybe someone will point out what we're both doing wrong.

I meant to type 'deserialisation exceptions' instead of 'deserialisation changes' aboveĀ