SharedPtr: Implement make_shared using adopt_shared
Some checks failed
continuous-integration/drone/pr Build is failing

This commit is contained in:
apio 2023-02-14 19:59:44 +01:00
parent 620810d720
commit 6fc02e042a
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -137,6 +137,12 @@ template <typename T> Result<SharedPtr<T>> adopt_shared(T* ptr)
return SharedPtr<T> { ptr, ref_count }; return SharedPtr<T> { ptr, ref_count };
} }
template <typename T, class... Args> Result<SharedPtr<T>> make_shared(Args... args)
{
T* raw_ptr = TRY(make<T>(args...));
return adopt_shared(raw_ptr);
}
template <typename T> Result<SharedPtr<T>> adopt_shared_if_nonnull(T* ptr) template <typename T> Result<SharedPtr<T>> adopt_shared_if_nonnull(T* ptr)
{ {
if (ptr) return adopt_shared(ptr); if (ptr) return adopt_shared(ptr);