You're making this way, way, way too hard. All current archives are implemented in terms of standard library input/output. Study the standard library. You will find that you can make your own custom streambuf and attach that to stream. This is how stringstream is implemented. Then instanticiate an archive using a stream with your custom streambuf and serialize to that. This is not hard to do and would provide a universal solution for all archives. Actually I would expect a web search would turn up source code for making a custom streambuf as this is the way the standard library was designed to be used. Of course if you're really lazy, you can just serialize to a string stream, retrieve the size of the string and throw it away. But that's too lazy - even for me. Robert Ramey Oh - if you've got nothing else to do, you can make a streambuf which does nothing but calcuates a CRC. I would find that useful. RR Ioannis Papadopoulos wrote:
Hi,
I want to calculate exactly how much space it is needed to serialize a number of objects. What I'm thinking is another class that implements the Saving Archive concept and only invokes sizeof() rather than actually writing anything.
From what I understand I should overload the << and & operators for this class to call save() or serialize() on the object, unless it is a POD (in which case the size is already known).
Has this been done before?
Thanks