"Robert Ramey"
OK
Heres the short explanation using float as an example:
Its not a great idea to set the tracking trait for float to tracking because you'll end up tracking ALL the floats int the archive.
So you make a very small class that just contains a float. That as wrapper class. This is to function just like a float except that it has a different class. So it will have the default serialization trace assigned since its not a primitive. This means it will be tracked by default.
struct tracked_float { float m_float; // the real data template<class Archive> void serialize(Archive &ar, unsigned int version){ ar & m_float; } // casting operators - not compiled float operator float () const { return m_float; } float & operator float() { return m_float; } };
Now just use tracked_float for those floats you want to serialize through a
Does 'just use' mean that one would now need to replace all occurrences of float* data members with tracked_float*'s? As in: class with_float_ptr { tracked_float* m_tracked_float_ptr; ... template<class Archive> void serialize(Archive &ar, const unsigned int version ) { ar & m_tracked_float_ptr; } }; Or is there a less intrusive manner? I'm just curious, as there are no raw pointers in anything that I've yet needed to serialize.
pointer and just float for other float variables.
This is more or less equivalent to using
BOOST_STRONG_TYPEDEF(tracked_float, float)
template<class Archive> void serialize(Archive &ar, tracked_float & tf){ ar & tf.m_float; }
I don't know if that helps - but there it is.
Jeff