Add intrusive_ptr<>::detach()

This provides a way to escape from automatic reference counting, and taking
manual control of the reference.  Useful when interfacing to a C API that
expects a pointer with an elevated reference count.

Similar to std::unique_ptr<>::release().
This commit is contained in:
Avi Kivity authored and Peter Dimov committed 2013-12-26 17:47:28 +02:00
1 parent d7fa365843
commit 73153d5797
3 files changed
+31

No files matched your search

@@ -151,6 +151,13 @@ public:
return px;
}
T * detach() BOOST_NOEXCEPT
{
T * ret = px;
px = 0;
return ret;
}
T & operator*() const
{
BOOST_ASSERT( px != 0 );