开发者

serialise nested unordered maps

开发者 https://www.devze.com 2022-12-13 19:27 出处:网络
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'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

精彩评论

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