
Peter Dimov wrote:
Carlo Wood wrote:
1) WHY does boost::serialization not support serialization of iterators?
It's very hard, if not impossible, in general.
3) My original question hasn't been answered: How can one serialize iterators with boost::serialization?
If you have access to the container to which the iterator i refers:
a) if the container is a map, you can serialize i->first, then on deserialization look up the key in the map using .find();
b) if the container is a sequence, and it has the same contents on deserialization as it does on serialization, you can serialize the index of the element - distance( c.begin(), i ).
LOL - this illustrates the kinds of issues that come up - not at all trivial. When read the original email - I speculated a little on the question before deciding that it wasn't trivial. My view was that serialization of an iterator would require previous serialization of the container that it belongs to. Hopefully one could leverage on the faclities already in the library to reconstruct the iterator on the newly loaded container. Food for thought Robert Ramey