0

How to serialize/deserialize with boost std::vector of boost::unordered_map like

vector<boost::unordered_map<uint64_t, Person* > *> town;

which represents town. All pointers are row on heap created with new. Is possible to deserialize on easy way without refactoring code to use shared_ptr ? Person also has function also

template<class Archive>
void serialize(Archive & archive, const unsigned int version){
...
}
ildjarn
  • 62,044
  • 9
  • 127
  • 211
PaolaJ.
  • 10,872
  • 22
  • 73
  • 111
  • 1
    Look like this is a problem which have been posed to you, -- you probably need to reformulate the question, including how you have attempted to solved it and then somebody can help you fix your attempt on a solution. – Soren May 29 '14 at 01:06
  • Boost.Serialization [automatically handles pointers](http://www.boost.org/libs/serialization/doc/tutorial.html#pointers). As long as `Person` is serializable, then `Pointer*` is no issue at all. What problem are you encountering? – ildjarn May 29 '14 at 01:48
  • @ildjarn Problem is when I want to deserialize I need all persons to be on heap same as all unordered_maps. – PaolaJ. May 29 '14 at 10:06

2 Answers2

1

unordered_* are not yet supported in Boost Serialization.

Either add the support or use the (deprecated) GCC hash_* containers

A sample of how to add support is in this answer of mine: C++ Boost.Serialization error for hash_map with custom objects as key

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
0

Boost has already supported the unordered_set and unordered_map since the version 1.5.6. You can just include the header file.

#include <boost/serialization/unordered_map.hpp>
#include <boost/serialization/unordered_set.hpp>
Halcao
  • 56
  • 1
  • 5