开发者

serialise nested unordered maps

I've got a variable with a declaration that looks like

boost::unordered_map< std::string, boost::unordered_map <long,int>, hashe::fnv_1a> _pl;

I need to serialise this to a file and and deserialise later. Should I just do a nested loop or can i do something ultracool with boost::serialisation? Any help pointing me towards nested declarations would be greatly开发者_JS百科 appreciated.

Thanks in advance!


You have to define template function of serialization of each type. Boost serialization can be easily implemented for vectors and maps. Simply define serialize function for each type.

template<class Archive> void serialize(Archive& ar,unsigned int version) 

For more help see some examples: Boost Serialization Example

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜