AK: Add adopt_own() to create a NonnullOwnPtr<T> from a T&

This commit is contained in:
Andreas Kling 2020-04-01 21:04:10 +02:00
parent ee6472fef2
commit 806d3d8e79
Notes: sideshowbarker 2024-07-19 08:00:46 +09:00

View File

@ -167,6 +167,12 @@ private:
T* m_ptr = nullptr; T* m_ptr = nullptr;
}; };
template<typename T>
inline NonnullOwnPtr<T> adopt_own(T& object)
{
return NonnullOwnPtr<T>(NonnullOwnPtr<T>::Adopt, object);
}
template<class T, class... Args> template<class T, class... Args>
inline NonnullOwnPtr<T> inline NonnullOwnPtr<T>
make(Args&&... args) make(Args&&... args)
@ -195,5 +201,6 @@ inline void swap(NonnullOwnPtr<T>& a, NonnullOwnPtr<U>& b)
} }
using AK::adopt_own;
using AK::make; using AK::make;
using AK::NonnullOwnPtr; using AK::NonnullOwnPtr;