Boost logo

Boost :

Subject: [boost] [serialization] working around the pointer_conflict exception?
From: T. Farago (farago1_at_[hidden])
Date: 2009-09-01 10:32:54

I have implemented the serialise library of BOOST to my own classes. Using a
single entry point it recursively goes through every member and saves the
values. Of course initial implementation yielded the pointer_conflict
expression as for example while going through objects A,B,C object A may
have a pointer to B, and only afterwards is B actually saved.

I tried - and thought - to fix this by using a two-phased approach. First I
save all the actual objects from the entry point, secondly only the
pointers. eg

save_objects = true;
ar & my_object;
save_objects = false;
ar & my_objects;

and inside every class:
class A {
int a;
int *b;
serialise() {
if (save_objects) {
ar & a;
} else {
ar & b;

This seemed sound but only during debugging did I realise that the second
run of the serialiser doesn't do anything since my_object is already saved.
So this won't work.

Does anyone have better ideas on solving this problem, or has encountered
and already solved this issue?

Using Opera's revolutionary e-mail client:

Boost list run by bdawes at, gregod at, cpdaniel at, john at