简体   繁体   English

Boost如何序列化STL容器?

[英]How does Boost serialize STL containers?

I need to know how Boost::Serialize works with STL containers - such as map, vector and list. 我需要知道Boost :: Serialize如何与STL容器一起工作 - 例如map,vector和list。

Specifically, does it saves the size of the entire container right before all the actual container data itself? 具体来说,它是否在所有实际容器数据本身之前保存整个容器的大小?

Can I read that size in order to know how large the STL container is? 我可以读取该尺寸以了解STL容器的大小吗?

I am on Win7, 64bit with Visual Studio 2010. 我在使用Visual Studio 2010的Win7,64位上。

Thanks. 谢谢。

Here is the source code for boost serializing std::vector s: http://www.boost.org/doc/libs/1_38_0/boost/serialization/vector.hpp 以下是boost序列化std::vector的源代码: http//www.boost.org/doc/libs/1_38_0/boost/serialization/vector.hpp

std::set s: http://www.boost.org/doc/libs/1_38_0/boost/serialization/set.hpp std::set s: http//www.boost.org/doc/libs/1_38_0/boost/serialization/set.hpp

std::list s: http://www.boost.org/doc/libs/1_38_0/boost/serialization/list.hpp std::list s: http//www.boost.org/doc/libs/1_38_0/boost/serialization/list.hpp

std::vector is pretty clear that it does. std::vector非常清楚它确实如此。 If you look in the http://www.boost.org/doc/libs/1_38_0/boost/serialization/collections_load_imp.hpp implementation header file we see: 如果您查看http://www.boost.org/doc/libs/1_38_0/boost/serialization/collections_load_imp.hpp实现头文件,我们会看到:

collection_size_type count;
//...
ar >> BOOST_SERIALIZATION_NVP(count);

in the load_collection function. load_collection函数中。 Both std::list and std::set serializer calls this directly. std::liststd::set serializer都直接调用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM