Boost logo

Boost :

Subject: Re: [boost] [serialization] working around the pointer_conflictexception?
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-09-01 12:42:29

T. Farago wrote:
> 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.

The following should work without problem

class A {
    int a;
    int *b;
    template<class Archive> void serialise(Archive & ar, const unsigned int
version) {
        ar & a;
        ar & b;

If you still have a problem you could save all the objects first

ar & my_obect;

You don't have to do anything else. The serialization library includes
the tracking of repeated objects.

Robert Ramey

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