如何释放从boost :: shared_ptr的指针? [英] How to release pointer from boost::shared_ptr?

查看:449
本文介绍了如何释放从boost :: shared_ptr的指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以提高:: shared_ptr的释放存储的指针而不删除它?

Can boost::shared_ptr release the stored pointer without deleting it?

我可以看到文档中没有释放功能存在,也是在帮助解释为什么它不提供释放功能,类似的东西释放不能对不是唯一的指针来完成。我的指针是唯一的。我怎样才能释放我的指针?
或提高智能指针类使用,让我释放指针?
我希望你不会说使用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.

<一个href=\"http://stackoverflow.com/questions/1833356/detach-a-pointer-from-a-shared-ptr/5995770#5995770\">See这个答案(已被标记为这个问题的副本)了解更多信息。

See this answer (which has been marked as a duplicate of this question) for more information.

这篇关于如何释放从boost :: shared_ptr的指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆