22 May 15:37
[serialization] Handling of references into a std::map
From: Bernhard Maeder <bernhard.maeder <at> zkb.ch>
Subject: [serialization] Handling of references into a std::map
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-05-22 13:39:04 GMT
Subject: [serialization] Handling of references into a std::map
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-05-22 13:39:04 GMT
Hello all
I'm trying to serialize a std::map along with some pointers that are referencing
onto some of the Value elements of that map. What I see now, is that those
references are not loaded correctly. Here's what I do:
#include <sstream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/map.hpp>
struct dummy
{
template<typename Archive>
void serialize(Archive & ar, const unsigned int version)
{
}
};
struct map_ref_test
{
std::map<std::size_t, dummy> m;
dummy * ref;
template<typename Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & m;
ar & ref;
}
(Continue reading)
, it is able to accomplish these things for
you and should thus make the serialization code much less verbose.
Bernhard
_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
RSS Feed