Does 'just use' mean that one would now need to replace all occurrences of float* data members with tracked_float*'s? As in:
All the ones you want to serialize as a pointer.
I expect there is another method which is less intrusive, but I would have
to think about it.
Robert Ramey
"Jeff Flinn"
"Robert Ramey"
wrote in message news:coqoda$2t4$1@sea.gmane.org... 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
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
its 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