
John Reid ha escrito:
Hi,
I had some problems serializing/deserializing a multi_index container. I've tried a work around of copying the container into a vector and serializing/deserializing this (which works). Does anyone know the conditions under which serialization of multi_index containers do not work? My guess is my operator< may not satisfy the requirements although it has stood up to all the testing I have been able to do so far.
I am using VS2005 with boost 1_33_1.
FYI I'm getting an archive exception from this code in ordered_index.hpp: void rearranger(node_type* position,node_type *x) {
[...]
}
Hello John, from your description looks like loading is failing because your operator< is not *serialization-compatible*, as required in http://www.boost.org/libs/multi_index/doc/reference/ord_indices.html#seriali... Serialization-compatibility formal definition is given at: http://boost.org/libs/multi_index/doc/reference/multi_index_container.html#s... What this means is, if you've got elements a,b and its corresponding deserialized equivalents a',b', then a<b must yield the same value (true or false) as a'<b' --assuming it is operator< that is used for sorting the index, which is the case if identity<element> is the key and the default sorting criterion is used. You can very easily spot the place where serialization-compatibility of operator< is determined to not hold by placing a breakpoint where the exception is thrown (line 1083 of ordered_index.hpp) and inspecting the values of arguments position and x. Please report your findings back or insist on me if you need further help. Good luck, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo