
Stefan Strasser wrote:
Hi everyone, Hi Robert, in case you'd like to answer this one, because I have a rather specific question about your library. Thank you in advance!
I'd like to serialize an object and later reconstruct it from the serialized data:
void save(T const &t){ ar << t; } T* load(){ T *t=new T(); //error ar >> *t; }
T might not have a default constructor. so load_construct_data should be used. apparently the way to do this is to serialize through a pointer:
void save(T const *t){ ar << t; } T *load(){ T *t; ar >> t; }
this works, but it causes the type T to be tracked, if its object tracking is set to track_selectively. I don't want that. but I can't set it to track_never either, because if the type is serialized at another point in the program through a pointer, the type should be tracked.
is there a solution to this? is there a serialization wrapper that says "don't track this type just because of this pointer"?
so you want "don't track this particular save - but leave others as normal" Try something like class A .... class UntrackedA : public A { ... }; BOOST_SERIALIZATION_TRACK(UntrackedA, track_never); .. A a; const Untracked & A ua(a); ar << ua; ... Untracked & A ua2(a); ar >> ua2; That would what would first occur to me. Robert Ramey