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
2013-12-26 17:47:28 +02:00
committed by Peter Dimov
parent d7fa365843
commit 73153d5797
3 changed files with 31 additions and 0 deletions
@@ -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 );