问题描述
boost::shared_ptr 可以释放存储的指针而不删除它吗?
Can boost::shared_ptr release the stored pointer without deleting it?
我可以看到文档中不存在发布功能,在常见问题解答中也解释了为什么它不提供发布功能,例如不能在非唯一指针上进行发布.我的指针是独一无二的.我怎样才能释放我的指针?或者使用哪个 boost 智能指针类可以让我释放指针?我希望你不会说使用 auto_ptr :)
I can see no release function exists in the documentation, also in the FAQ is explained why it does not provide release function, something like that the release can not be done on pointers that are not unique. My pointers are unique. How can I release my pointers ? Or which boost smart pointer class to use that will allow me releasing of the pointer ? I hope that you won't say use auto_ptr :)
推荐答案
您需要使用一个删除器,您可以请求不删除底层指针.
You need to use a deleter that you can request not to delete the underlying pointer.
看到这个答案(已经标记为与此问题重复)以获取更多信息.
See this answer (which has been marked as a duplicate of this question) for more information.
这篇关于如何从 boost::shared_ptr 释放指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!