Boost logo

Boost Users :

From: Martin Trappel (0xCDCDCDCD_at_[hidden])
Date: 2008-06-03 09:55:50


sam p wrote:
> Is it right to use serialization library in the following environment,
>
> **********************
> Main1.cpp : Compiled with Gcc stores map in /tmp/z
> **********************
> (1) main1.cpp
> --------------------
> #include <map>
> #include<string>
> #include <boost/archive/text_oarchive.hpp>
> #include <boost/serialization/map.hpp>
> #include <boost/serialization/string.hpp>
>
> int main()
> {
> std::ofstream f("/tmp/z");
> boost::archive::text_oarchive oar(f);
> std::map<std::string, std::string> a;
> ..... //Some data added to this map
>
> oar & a;
> return 0;
> }
> **************************
> main2.cpp : Compiled with Forte compiler (or say older version of GCC)
> loads map stored in /tmp/z
> *******************************
> (2) main2.cpp
> -----------------------------------------------
> #include <map>
> #include<string>
> #include <boost/archive/text_iarchive.hpp>
> #include <boost/serialization/map.hpp>
> int main()
> {
> std::ifstream f("/tmp/z");
> boost::archive::text_iarchive iar(f);
> std::map<std::string, std::string> a;
>
> iar & a;
>
> return 0;
> }
> ***********************************
>
> Can such use create problems especially with STL and their vendor
> specific implementations?
>

IMHO, usage of any serialization API should never, ever introduce
problems across different compilers. That's the whole point of
serialization, I'd say :-)

Having used boost::serialization once, I would say your code will work
without problems across different compilers if it works on one of them.
(The serialization API knows nothing of the Implementation details of
the STL collections, it does its work just with the std interfaces.)

br,
Martin


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