mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: Add templated NonnullOwnPtr::release_nonnull()
This allows you to release a NonnullOwnPtr<T> into a NonnullOwnPtr<U>
This commit is contained in:
@@ -155,6 +155,13 @@ public:
|
||||
::swap(m_ptr, other.m_ptr);
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullOwnPtr<U> release_nonnull()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return NonnullOwnPtr<U>(NonnullOwnPtr<U>::Adopt, static_cast<U&>(*leak_ptr()));
|
||||
}
|
||||
|
||||
private:
|
||||
void clear()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user