如何使用 Boost 序列化序列化 Boostscoped_array?
我正在尝试使用 Boost 序列化来序列化 Boost scoped_array
,但编译器 (VS2008) 给出以下错误消息:
error C2039: 'serialize' : is not a member of 'boost::scoped_array<T>'
如何序列化 scoped_array
?我应该为此添加一个 Boost 库吗?
I am trying to serialize a Boost scoped_array
using Boost serialization but the compiler (VS2008) is giving me the following error message:
error C2039: 'serialize' : is not a member of 'boost::scoped_array<T>'
How do I serialize a scoped_array
? Is there a Boost library that I should be including for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
猜猜不是。
scoped_ptr
和scoped_array
旨在跟踪本地范围内的指针。将内容序列化并稍后读回似乎违背了课程的意图。
Guess not. The
scoped_ptr
andscoped_array
are designed for keeping track of pointers in a local scope.Having the content serialized and read back later seems to be against the intent of the class.
序列化数组本身,而不是它周围的内存管理包装器。
Serialise the array itself, not a memory-managing wrapper around it.
这是我最终使用的解决方案(对称——适用于保存和加载):
Here is a solution that I ended up using (symmetric -- works for saving and loading):