问题描述
的boost ::序列具有升压内置支持:: shared_ptr的<方式>
Boost::Serialization has builtin support for boost::shared_ptr<>
.
有没有使用这种方式支持的std :: TR1的:: shared_ptr的&LT;&GT;
太结果
是否有可能从投的std :: tr1 :: shared_ptr的&LT;&GT;
到的boost :: shared_ptr的&LT;&GT;
?
Is there a way to use this support for std::tr1::shared_ptr<>
too?
Is it possible to cast from std::tr1::shared_ptr<>
to boost::shared_ptr<>
?
推荐答案
一个铸造不会因为不同的实现成为可能。还创建一个shared_ptr的类型与来自get()方法在其他的shared_ptr类型的返回值的实例将无法正常工作作为参考countings会到0在不同的点在你的code导致的对象删除前的最后一次使用它。
我不是的boost ::序列化的专家,但作为接口的std :: tr1 :: shared_ptr的&LT;>和boost :: shared_ptr的&LT;>几乎是一样的,很可能,你可以只克隆序列化/反序列化$ C $升压ç:: shared_ptr的&LT;>,只需要更换的shared_ptr的命名空间
A casting will not be possible as implementations differ. Also creating an instance of the one shared_ptr type with the value returned from get() on the other shared_ptr type will not work correctly as the reference countings will go to 0 at different points in your code which leads to deletion of the object before the last use of it.I am not an expert of boost::serialization but as the interfaces of std::tr1::shared_ptr<> and boost::shared_ptr<> are nearly identical it is very likely that you can just clone the serialization/deserialization code of boost::shared_ptr<> and only have to replace the namespace of the shared_ptr.
这篇关于升压序列化 - 序列化的std :: TR1的:: shared_ptr的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!