
Hi folks,
I stumbled over a strange behavior in the serialization.
Basically I want to write multiple entries into the same archive. The
data is a map of an index and some shared_ptr for the values.
Writing/reading are working but produce wrong results with the provided
minimal example.
I'm using boost 1.49 under Visual Studio 2010 64bit.
I've also tried the code without the use of shared_ptr and without a
map. Both version are working fine. The combination however fails.
What am I doing wrong?
cheers
Sebastian
<snip>
#include <map>
#include <fstream>
#include

On 03/10/2013 11:52, Sebastian Messerschmidt wrote:
Hi folks,
(...) What am I doing wrong?
Hi Sebastian, This is because you are serializing the same shared_ptr over and over again so it's only serialized the first time and all the other times the library notices it's the same pointer and will only serialize a "reference" to it. See http://www.boost.org/doc/libs/1_49_0/libs/serialization/doc/serialization.ht... which explains this. I hope this helps, MAT.

Hi Mathieu, Thank you for the hint. I solved it by wrapping the shared_ptr into class holding it and there serializing the data held by the pointer. cheers Sebastian
On 03/10/2013 11:52, Sebastian Messerschmidt wrote:
Hi folks,
(...) What am I doing wrong?
Hi Sebastian,
This is because you are serializing the same shared_ptr over and over again so it's only serialized the first time and all the other times the library notices it's the same pointer and will only serialize a "reference" to it. See http://www.boost.org/doc/libs/1_49_0/libs/serialization/doc/serialization.ht... which explains this.
I hope this helps, MAT.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Mathieu Champlon
-
Sebastian Messerschmidt