"Greg" <grisharav@gmail.com> wrote in message news:gn48jb$u1$1@ger.gmane.org...Hey, thanks for the reply.
The problem is that the code doen't compile, not about runtime.
However, I have identified the problem - the code below doesn't compile with /Za (With laguage extensions disbaled)
The code traps in boost\archive\detail\oserializer.hpp line 538:
template<class Archive, class T>
inline void save(Archive & ar, T &t){
// if your program traps here, it indicates that your doing one of the following:
// a) serializing an object of a type marked "track_never" through a pointer.
// b) saving an non-const object of a type not markd "track_never)
// Either of these conditions may be an indicator of an error usage of the
// serialization library and should be double checked. See documentation on
// object tracking. Also, see the "rationale" section of the documenation
// for motivation for this checking.
BOOST_STATIC_WARNING(check_tracking<T>::value);
save(ar, const_cast<const T &>(t));
}
When compiling with language extensions enabled the code compiles fine.
This remains a question, why does this code require non standard extension?
This might an issue for a developer that wants to write more or less portable code.
Suggestion anyone?
Greg"Robert Ramey" <ramey@rrsd.com> wrote in message news:gn0h34$9ae$1@ger.gmane.org...It might be help to indicate the error and which line tripped it.In the meantimea) binary streams should be opened with ios::binaryb) I don't remember what std::cout is derived from. Try stringstream or fstreamRobert Ramey"Greg Ravikovich" <grisharav@gmail.com> wrote in message news:442cf10a0902110433h2aa8ef69k71cc660c8e7e492b@mail.gmail.com...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 mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users