
Thanks for both your answers! Your proposals:
Robert Ramey wrote: just use the base class implementation of serialize function via inheritance
and Am 02.04.2013 16:35, schrieb Guy Premont:
template<class Archive> void serialize(Archive & ar, const unsigned int version) { boostVx::serialization::serialize(ar, static_cast
(*this), version); } };
...have the problem that even though it prevents tracking the actual
object reference of type T - which might be track_selectively - never
reaches the serialization library. only a pointer of type NoTracking<T>
is passed on, which is track_never. (note: serialization::serialize()
does not call basic_oarchive::save_object())
so if the object graph stores a pointer to the root object, the root
object is serialized twice and duplicated on deserialization.
this might seem like an outlandish example, but a simple tree with nodes
that have parent pointers is one.
on the other hand, if the object reference DOES reach the serialization
library it is just like serializing the object, instead of a pointer,
and I have the problem described in my initial email (load_construct_data).
the only solution I could come up with is duplicating some
implementation details in "namespace archive" and create a
nontracking_pointer_oserializer and call basic_oarchive::save_pointer()
directly:
A *a=new A;
nontracking_pointer_oserializer