From 806d3d8e79955eef2fb935c982bd9704ee5a9255 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 1 Apr 2020 21:04:10 +0200 Subject: [PATCH] AK: Add adopt_own() to create a NonnullOwnPtr from a T& --- AK/NonnullOwnPtr.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h index c3a78a6ff58..c34b09de2fd 100644 --- a/AK/NonnullOwnPtr.h +++ b/AK/NonnullOwnPtr.h @@ -167,6 +167,12 @@ private: T* m_ptr = nullptr; }; +template +inline NonnullOwnPtr adopt_own(T& object) +{ + return NonnullOwnPtr(NonnullOwnPtr::Adopt, object); +} + template inline NonnullOwnPtr make(Args&&... args) @@ -195,5 +201,6 @@ inline void swap(NonnullOwnPtr& a, NonnullOwnPtr& b) } +using AK::adopt_own; using AK::make; using AK::NonnullOwnPtr;