On Fri, Sep 18, 2009 at 14:30, Peter Soetens
On Thu, Sep 17, 2009 at 18:33, Robert Ramey
wrote: Peter Soetens wrote:
I might do what you suggest or look for another serialization solution.
Given the limited scope of what you want to do, it wouldn't be THAT hard to make your own archive. Take a look at "trivial_archive" in the documentation and build from that.
Encouraged by your and Stefan's suggestions, I've spent another day at looking what the possibilities are.
1. I first created my own binary_?archive classes which inherited from common_?archive. This resulted in pulling in the library with the 'behind the scenes type tracking'. It seems, inheriting from common is not an option for me if I want 'zero-allocation' serialization. Correct ? (I also tested the demo_fast_archive.cpp extended with no_header, but that one also allocated).
2. I then tried to work further on Stefan's code snippet. It works, but indeed only for 'primitive_type's. I *think* I need functionality upto the 'object_serializable' if I want std::vector<T> as well. Since Stefan's operator& consumes every T, I'll need one operator& for each primitive type, and then an operator& that tries to save/load using free functions of the not primitive type.
3. It looks that I'll have to implement the Archive concept from scratch or at least based on Stefan's code and the load_binary/save_binary code from binary_?archive.
I'm got so far that I 'hacked' an allocation free output and output archive, and output works like a charm. But for the input side, I can't seem to get the ADL to work for serializing the nvt<T> case. The point I'm struggling with is that sometimes save() is a member function and sometimes it's a free function, and I can't get to the selection logic. The archiver in attachment fails to compile on line 68 where it says 'no matching function for call to ‘load(boost::archive::mqueue_tiny_iarchive&, const boost::serialization::nvp<double>&, int)', when reading back in an std::vector<double>. I'm aware that this is no longer an serialization question, but I'm just one compile error away from the real solution :-) Maybe it wouldn't hurt to include some examples for serializing level 1/2 objects which just implement the Archive concept interface. Any hints greatly appreciated. Peter