[Boost-users] boost serialization & C++ STL

147 views
Skip to first unread message

sam p

unread,
Jun 2, 2008, 11:06:45 AM6/2/08
to boost...@lists.boost.org
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?
 
Thanks,
Sameer

Martin Trappel

unread,
Jun 3, 2008, 9:55:50 AM6/3/08
to boost...@lists.boost.org

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 mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Tim St. Clair

unread,
Jun 3, 2008, 11:54:07 AM6/3/08
to boost...@lists.boost.org
I general... you should be fine across compilers. 

I have noticed oddities on 1.35.0 which have show differences across compilers, but I have had no problems in 1.34.1

My guess is that these items will be fixed in a 1.35.X release. 

Cheers,
Tim
--
Regards,
Timothy St. Clair
[timo...@gmail.com]
Reply all
Reply to author
Forward
0 new messages