如何对 std::stack 使用 boost::serialization?
我知道我们可以将 boost::serialization 用于 std::vector 、 list 、map 等,只要我包含相应的 boost 头文件,例如:
#include <boost/serialization/list.hpp>
但是如何将 boost::serialization 用于 std::stack ?
谢谢
I know we can use boost::serialization for std::vector , list ,map etc as long as I include the corresponding boost header file like:
#include <boost/serialization/list.hpp>
But how could I use boost::serialization for std::stack ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这已经很旧了,但我最近遇到了这个问题。我对使用 std::deque 的解决方案并不满意,因为我实际上只需要一个堆栈接口。目前,boost 通过按此顺序包含这些头文件来支持 std::stack 的序列化。
完整的示例如下所示:
I know this is old, but I recently came across this problem. I was not satisfied with the solution of using std::deque because I really needed only a stack interface. Currently, boost support serialization of std::stack this by including these header files in this order
A complete example would look something like:
将
std::stack
替换为std::deque
并包含:Replace
std::stack
withstd::deque
and include: