Boost logo

Boost Users :

Subject: [Boost-users] [serialization] backwards compatibility of vector (de)s11n
From: Ewald Peiszer (ewald.peiszer_at_[hidden])
Date: 2011-11-22 09:53:34


Hi list,

I am migrating from Boost v1.35 to a new version. I have, however, some
legacy serialized strings that I want to be readable by the new version.

After some testing I found that apparently the newer version (in this
case 1.40) cannot correctly deserialize std::vector instances from 1.35
generated strings. Can anyone give my a pointer as to what may be the
problem here?

Thanks a lot!
Ewald

==Details==

I use text archives, and gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)

The test vector is a structure with 2 items, the long integers 1 and 2.

Archive string for respective lib versions:

1.35 archive: 22 serialization::archive 4 2 1 2
1.40 archive: 22 serialization::archive 5 2 0 1 2

Now:

---------(code snippet)
// includes
#include <boost/serialization/vector.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>

std::vector<long> testvector;
std::string val = "22 serialization::archive 4 2 1 2"; // v1.35 archive
{
std::stringstream ss(std::stringstream::in | std::stringstream::out);
ss << val << std::endl;
boost::archive::text_iarchive ia(ss);
ia >> BOOST_SERIALIZATION_NVP(testvector);
}

--------

Result when executing with lib v1.40: testvector contains two elements,
{2, 2} -- instead of {1, 2}

Note: s11n and de-s11n with the same lib version works perfect.


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