1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

AK: Move try_make_ref_counted() to NonnullRefPtr.h

This commit is contained in:
Nico Weber 2023-02-11 06:37:21 -05:00 committed by Tim Flynn
parent 3c842d9d76
commit 0c4bbf5be3
2 changed files with 14 additions and 14 deletions

View file

@ -328,24 +328,10 @@ inline RefPtr<T> adopt_ref_if_nonnull(T* object)
return {};
}
template<typename T, class... Args>
requires(IsConstructible<T, Args...>) inline ErrorOr<NonnullRefPtr<T>> try_make_ref_counted(Args&&... args)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) T(forward<Args>(args)...));
}
// FIXME: Remove once P0960R3 is available in Clang.
template<typename T, class... Args>
inline ErrorOr<NonnullRefPtr<T>> try_make_ref_counted(Args&&... args)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) T { forward<Args>(args)... });
}
}
#if USING_AK_GLOBALLY
using AK::adopt_ref_if_nonnull;
using AK::RefPtr;
using AK::static_ptr_cast;
using AK::try_make_ref_counted;
#endif