mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +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:
parent
788293ead8
commit
d69fd87b50
Notes:
sideshowbarker
2024-07-19 06:50:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d69fd87b503
1 changed files with 7 additions and 0 deletions
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue