Boost Serialization unordered_multimap
Hi.
How can I serialize an unordered_multimap with boost.Serialization library? I have tried this:
Code:
namespace boost {
namespace serialization {
template<class Archive, typename X, typename Y>
void load(Archive & ar, boost::unordered_multimap<X,Y> & g, const unsigned int version)
{
std::size_t size;
ar & size;
while(size--)
{
std::pair<X,Y> m;
ar & m;
g.insert(m);
}
}
template<class Archive, typename X, typename Y>
void save(Archive & ar, const boost::unordered_multimap<X,Y> & g, const unsigned int version)
{
std::size_t size = g.size();
ar & size;
for(boost::unordered_multimap<X,Y>::iterator it = g.begin(); it != g.end(); ++it)
{
ar & (*it);
}
}
}
}
But it didn't work. The compiler complains about a serialize method is missing in boost::unordered_multimap but as I know should it work if I define a save and load function in the serialization namespace, but it doesn't.
Any clue what I am doing wrong?
Thanks in advance.