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:
@@ -330,6 +330,13 @@ void test()
|
||||
|
||||
BOOST_TEST(get_pointer(px) == px.get());
|
||||
}
|
||||
|
||||
{
|
||||
boost::intrusive_ptr<X> px(new X);
|
||||
X* detached = px.detach();
|
||||
BOOST_TEST(detached->use_count() == 1);
|
||||
delete detached;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace n_access
|
||||
|
||||
Reference in New Issue
Block a user