简体   繁体   English

Boost序列化-序列化不可复制但可移动的对象?

[英]Boost serialization - Serialize noncopyable but movable objects?

Is it possible somehow? 有可能吗? It doesnt work out of the box since it tries to copy objects when the object gets unserialized 它无法立即使用,因为当对象未序列化时它会尝试复制对象

Update 1: These objects are noncopyable just because they allocate memory, once it is allocated I dont see any reason to copy when it can be moved. 更新1:这些对象是不可复制的,只是因为它们分配了内存,一旦分配了内存,我便看不到有任何理由可以复制。 The unserialization part should be kept as fast as possible. 反序列化部分应保持尽可能快。

I had a similar problem once some time ago, and IIRC I did not find any solution to this, so instead I unserialized an object of another type and fed that into the actual object's construtor. 不久前,我遇到了类似的问题,而IIRC却没有找到任何解决方案,因此我反序列化了另一种类型的对象,并将其输入到实际对象的构造函数中。 That other type was designed just to make deserialization fast and move its contents to the acutal object. 设计另一种类型只是为了快速反序列化并将其内容移动到实际对象。

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

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