i've got simple class unordered map , serialize function:
#include <boost/unordered_map.hpp> #include <boost/serialization/unordered_map.hpp> class to_serialize { boost::unordered_map<int, int> m_map; public: friend class boost::serialization::access; template<class archive> void serialize(archive & ar, const unsigned int) { ar & m_map; } };
now try create ts object , serialize it:
#include <fstream> #include <boost/archive/binary_iarchive.hpp> #include <boost/archive/binary_oarchive.hpp> #include "ts.cpp" int main() { to_serialize ts; std::ofstream ofs("saved.bin"); { boost::archive::binary_oarchive oa(ofs); oa << ts; } ofs.close(); }
this fails compile, with:
boost/serialization/access.hpp:116:9: error: 'class boost::unordered::unordered_map<int, int>' has no member named 'serialize'
i don't understand i'm missing here? boost/serialization/unordered_map.hpp seems declare , define serialize function unordered map, guess that's not enough?
it looks answer simple -- boost implements serialization of stl unordered_map, not own boost::unordered_map version :(.
Comments
Post a Comment