From b9fb4c1ce6c7ee67b8f662af556029fc00f2283d Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 14 Feb 2023 19:59:44 +0100 Subject: [PATCH] SharedPtr: Implement make_shared using adopt_shared --- luna/include/luna/SharedPtr.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/luna/include/luna/SharedPtr.h b/luna/include/luna/SharedPtr.h index 2ddf3b5d..8197f4ab 100644 --- a/luna/include/luna/SharedPtr.h +++ b/luna/include/luna/SharedPtr.h @@ -137,6 +137,12 @@ template Result> adopt_shared(T* ptr) return SharedPtr { ptr, ref_count }; } +template Result> make_shared(Args... args) +{ + T* raw_ptr = TRY(make(args...)); + return adopt_shared(raw_ptr); +} + template Result> adopt_shared_if_nonnull(T* ptr) { if (ptr) return adopt_shared(ptr);