Search code examples
c++boostshared-ptr

How to release pointer from boost::shared_ptr?


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

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 :)


Solution

  • 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.