Boost logo

Boost Users :

From: Gerald Fordyce (gfordyce_at_[hidden])
Date: 2007-11-07 10:11:59


Hi,

I am attempting to use boost::serialization to serialize a simple
derived class to an XML archive. I have no problem creating a text
archive - code compiles and the text archive contains both base class
and derived class members. If I switch to the
boost::archive::xml_oarchive it no longer compiles. Here is the code
creating the archive:

const DerivedClass obj;

std::string filename = "fooBar.xml";
std::ofstream ofs(filename.c_str());
assert(ofs.good());
{
        boost::archive::xml_oarchive oa(ofs);
        oa << obj;
}

Here is the gcc-4.1.2 compiler output (Ubuntu):

/usr/local/include/boost-1_34/boost/archive/basic_xml_oarchive.hpp: In
member function ‘void
boost::archive::basic_xml_oarchive<Archive>::save_override(T&, int)
[with T = const DerivedClass, Archive = boost::archive::xml_oarchive]’:
/usr/local/include/boost-1_34/boost/archive/detail/interface_oarchive.hpp:79: instantiated from ‘Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = const DerivedClass, Archive = boost::archive::xml_oarchive]’
mkevents.cpp:81: instantiated from here
/usr/local/include/boost-1_34/boost/archive/basic_xml_oarchive.hpp:83:
error: invalid application of ‘sizeof’ to incomplete type
‘boost::STATIC_ASSERTION_FAILURE<false>’

So I'm wondering if the requirements for using txt_oarchive are
different than for xml_oarchive? It seems they should both work the
same.

Thanks
Gerald


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