Robert Ramey wrote:
This is a different problem.
DynamicArray<A> ArrayOfAs; ArrayOfAs.Element = new A[5]; ArrayOfAs.Size = 5; A* secondElement = &ArrayOfAs.Element[1];
std::stringstream stream; { boost::archive::text_oarchive oa(stream); oa & secondElement; // new object created here oa & ArrayOfAs; // attempt to reload an already loaded object
to new address - throw exception - pointer conflict
}
I think over here we have a solution to try. I believe at saving boost::serialization creates a map (object address -> object id) and at loading the lib creates the reverse map (object id -> object address) How inside the archive could I write a function like this: ObjID GetObjectID(void* objectAddress); Usage will be like this: class A { template<class Archive> void save(Archive & ar, const unsigned int version) const { ... ObjID objId = ar.GetObjectID(this); ... } }; Also, after loading is done and the load map is created, how inside the archive could I implement a function like this: void* GetObjectAddress(ObjID objId); Usage will be like this: ... ObjID objId; std::stringstream stream; boost::archive::text_iarchive ia(stream); ia & someObj; ia & objId; void* p = ar.GetObjectAddress(objId); ... Ivan