boost::serialization doesn't support iterators?

I looked for hours in the docs, because I couldn't believe
that a serialization library that supports deep copying of
pointers and STL containers wouldn't even MENTION iterators
(after all, iterators are the pointers of the STL).
However, it seems that boost::serialization simply does not
support serializing iterators! Is this true?
I really need to serialize iterators, how can I do that?
--
Carlo Wood

'Carlo Wood' wrote:
I looked for hours in the docs, because I couldn't believe that a serialization library that supports deep copying of pointers and STL containers wouldn't even MENTION iterators (after all, iterators are the pointers of the STL).
lol - believe it !!
However, it seems that boost::serialization simply does not support serializing iterators! Is this true?
True.
I really need to serialize iterators, how can I do that?
I don't think it would be all that tough - but it would require fairly intimat knowledge of how the standard containers and iterators work. Feel free to do it. Good Luck Robert Ramey

On Fri, Mar 10, 2006 at 09:16:27PM -0800, Robert Ramey wrote:
'Carlo Wood' wrote:
I really need to serialize iterators, how can I do that?
I don't think it would be all that tough - but it would require fairly intimat knowledge of how the standard containers and iterators work. Feel free to do it.
Good Luck
Robert Ramey
I asked you first in a private mail, and all you had to
say was: interesting question! Ask it on one of boosts
mailinglists and I'll answer it there.
Is the above the "Answer" you had in mind?
1) WHY does boost::serialization not support serialization
of iterators?
2) Why does the documentation not mention this?
3) My original question hasn't been answered: How can
one serialize iterators with boost::serialization?
Imho, it requires intimate knowledge of the serialization
library a lot more than knowledge of the STL; which is
why I think this should be added to the library by people
who are already familiar with how this library works (you).
I suppose that 'tracking' needs to be turned on for
something, but for what? The iterator type(s)? Will that
then work? I cannot answer those questions without
knowing the details of how this library works. I think
it's unfair to tell me "good luck".
--
Carlo Wood

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 ).

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

Carlo Wood wrote:
On Fri, Mar 10, 2006 at 09:16:27PM -0800, Robert Ramey wrote:
'Carlo Wood' wrote:
I really need to serialize iterators, how can I do that?
I don't think it would be all that tough - but it would require fairly intimat knowledge of how the standard containers and iterators work. Feel free to do it.
Good Luck
Robert Ramey
I asked you first in a private mail, and all you had to say was: interesting question! Ask it on one of boosts mailinglists and I'll answer it there.
Is the above the "Answer" you had in mind?
I was hoping someone else might have a better answer. For all I know someone has already done this and might be willing to post it to the vault.
1) WHY does boost::serialization not support serialization of iterators?
No one has done it. In fact, no one has yet even mentioned it so it doesn't seem to be a common desire. I concede it might be useful or even indispensable.
2) Why does the documentation not mention this?
The mentions the things that are included. It would make the documentation too long to mention all the things that are not included.
3) My original question hasn't been answered: How can one serialize iterators with boost::serialization? Imho, it requires intimate knowledge of the serialization library a lot more than knowledge of the STL;
OK - I'll concede it requires pretty good knowledge of both.
which is why I think this should be added to the library by people who are already familiar with how this library works (you).
lol - I can sympathize even though I might disagree. I am a contract software developer/consultant so every hour I spend on boost is one hour I can't dedicate to earning a living. When I'm out of work I can spend some time on it but that's not currently the case. Currently I can't afford to spend the time to do it. Of course if your company wants to hire me to add this, that might change the situation somewhat.
I suppose that 'tracking' needs to be turned on for something, but for what? The iterator type(s)? Will that then work? I cannot answer those questions without knowing the details of how this library works.
I would have to consider this issue in more depth before I could answer those questions. The documentation should contain all the information required to implement this. If it doesn't, then I would prefer to invest effort in improving the manual.
I think it's unfair to tell me "good luck".
maybe -maybe I was a tiny bit dismisive but I didn't mean any offense. The real an interesting question here is "What is the serialization library" There are two ways of looking at: a) All the code needed to serialze data in C++ programs. or b) All the code need to construct archives and serializers along with useful implementation examples. Of course it's both. But from my perspective it has to be b). My interest now runs to fixing the most arcane bugs, investigating performance issues, and improving the documentation to make it easier to do the kinds of things you mention. Robert Ramey

On Sat, Mar 11, 2006 at 02:58:59PM -0800, Robert Ramey wrote:
Of course if your company wants to hire me to add this, that might change the situation somewhat.
My company? I don't even have a job. I'm a full-time open source programmer, not getting paid a dime for what I do (all my projects are licensed GPL or QPL etc, and free for download from sourceforge and the like. Now before you ask how I make a living: I hardly do, I'm poor as hell. I understand if you don't have time, but please realize that I spend WAY more time on free software than you (...)
"What is the serialization library"
b) All the code need to construct archives and serializers along with useful implementation examples.
Of course it's both. But from my perspective it has to be b). My interest now runs to fixing the most arcane bugs, investigating performance issues, and improving the documentation to make it easier to do the kinds of things you mention.
Ok, that explains why STL iterators aren't supported (yet).
Of course I'm willing to give it a try, but I'll need help.
I'll ask questions on this list in order to be able to
write an implementation; hopefully someone will be able to
answer those questions.
Thanks,
Carlo Wood

"'Carlo Wood'" wrote:
I really need to serialize iterators, how can I do that?
You may take look on Boost.Multi-Index. It is serializable and its iterators too. The library can be used as a drop-in replacement for std::set, std::map and std::list. /Pavel _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Pavel Vozenilek wrote:
"'Carlo Wood'" wrote:
I really need to serialize iterators, how can I do that?
You may take look on Boost.Multi-Index. It is serializable and its iterators too.
Hmmm - maybe the implementation of this functionality can be copied for standard containers. Robert Ramey

Robert Ramey ha escrito:
Pavel Vozenilek wrote:
"'Carlo Wood'" wrote:
I really need to serialize iterators, how can I do that?
You may take look on Boost.Multi-Index. It is serializable and its iterators too.
Hmmm - maybe the implementation of this functionality can be copied for standard containers.
I'm afraid it can't --Serialization of B.MI iterators is intrusive and depends on the internal representation of the iterators. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (6)
-
'Carlo Wood'
-
Carlo Wood
-
Joaquín Mª López Muñoz
-
Pavel Vozenilek
-
Peter Dimov
-
Robert Ramey