forked from boostorg/smart_ptr
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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user