SharedPtr: Implement make_shared using adopt_shared
This commit is contained in:
parent
be408c4cdb
commit
b9fb4c1ce6
@ -137,6 +137,12 @@ template <typename T> Result<SharedPtr<T>> adopt_shared(T* ptr)
|
||||
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)
|
||||
{
|
||||
if (ptr) return adopt_shared(ptr);
|
||||
|
Loading…
Reference in New Issue
Block a user