Boost logo

Boost Users :

Subject: [Boost-users] [serialization] text_oarchive problem
From: Greg Ravikovich (grisharav_at_[hidden])
Date: 2009-02-11 07:33:14


Hello all,
I'm using boost 1.37 on msvc 9.
I have a compilation problem when serializing to a text_oarchive.
The problem doesn't happen when serializing to a binary_oarchive. here's a
sample code:

#include <boost/test/unit_test.hpp>

#include <boost/serialization/serialization.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/tracking.hpp>

struct SerializableStruct
{
   int m_data;
};

namespace boost
{
   namespace serialization
   {
      template<class Archive>
      void serialize(Archive & ar, SerializableStruct & s, unsigned int )
      {
         ar & s.m_data;
      }
   }
}

BOOST_CLASS_TRACKING(SerializableStruct,boost::serialization::track_never);

BOOST_AUTO_TEST_SUITE(TestGeneralSerialize)

BOOST_AUTO_TEST_CASE(TestTextArchive)
{
   boost::archive::text_oarchive out(std::cout);
   SerializableStruct s;
   s.m_data = 10;
   out << s;
}

BOOST_AUTO_TEST_CASE(TestBinaryArchive)
{
   std::stringstream str;
   boost::archive::binary_oarchive out(str);
   SerializableStruct s;
   s.m_data = 10;
   out << s;
}

BOOST_AUTO_TEST_SUITE_END();

By the way,
the following code compiles fine under boost 1.35 and fails to compile under
boost 1.36, 1.37.
Comment out the TestTextArchive and the code compiles fine.
Any help will be appreciated.

Greg



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