I'm sorry if this appears twice; I received an e-mail saying it couldn't be
sent because I hadn't subscribed to the mailing list.
When I run the following code, I get this error:
terminate called after throwing an instance of
'boost::archive::xml_archive_exception'
what(): uninitialized exception
Abort
However, if I substitute BOOST_SERIALIZATION_NVP for the make_nvp function,
it works fine. Am I doing something wrong, or is this a bug?
#include <iostream>
#include <fstream>
#include <string>
#include
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::remove;
}
#endif
#include
#include
#include
#include
class A
{
public:
A() {}
virtual ~A() {}
int a;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
//ar & BOOST_SERIALIZATION_NVP(a);
ar & boost::serialization::make_nvp("example field",a);
};
};
void
restore( const char * filename)
{
A s;
// open the archive
std::ifstream ifs(filename);
assert(ifs.good());
boost::archive::xml_iarchive ia(ifs);
// restore the schedule from the archive
ia >> BOOST_SERIALIZATION_NVP(s);
}
int main(int argc, char *argv[])
{
std::string filename("/tmp/wtf.xml");
{
A s;
// make an archive
std::ofstream ofs(filename.c_str());
assert(ofs.good());
boost::archive::xml_oarchive oa(ofs);
oa << BOOST_SERIALIZATION_NVP(s);
}
printf("---\n");
restore( filename.c_str());
return 0;
}
--
View this message in context: http://www.nabble.com/Bug-in-serialization%3A%3Amake_nvp--tp25304627p2530462...
Sent from the Boost - Users mailing list archive at Nabble.com.