j
k
j a
j l
Hello, I am trying to use boost::archive::xml_oarchive to serialize a vector > >. When I examine the serialized xml file, I see that some of the map elements are duplicated which causes an assertion when I try to load the file because a map cannot have two elements with the same key. I would appreciate any insight into this error. Thank you Thomas D'Silva /include/boost/serialization/collections_load_imp.hpp:69: void boost::serialization::stl::archive_input_map::operator()(Archive&, Container&) [with Archive = boost::archive::xml_iarchive, Container = std::mapstd::string, std::allocator > >]: Assertion `result.second' failed. #include #include #include #include #include #include using namespace std; using namespace boost::filesystem; class DistributionTable { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(neTable); ar & BOOST_SERIALIZATION_NVP(mappedTable); } vector > > neTable; vector > > mappedTable; public: DistributionTable(){}; }; void saveTable(const DistributionTable &t, string filename) { ofstream ofs(filename.c_str()); boost::archive::xml_oarchive oa(ofs); oa <>BOOST_SERIALIZATION_NVP(t); }
Back to the thread
Back to the list