AK: Make (Nonnull)OwnPtr work with abstract classes

Clang produced a compile error at this requires statement if `T` was an
abstract class.
This commit is contained in:
Daniel Bertalan 2021-06-25 07:33:15 +02:00 committed by Ali Mohammad Pur
parent b97a00d4b1
commit 3162c9e214
Notes: sideshowbarker 2024-07-18 11:05:45 +09:00
2 changed files with 2 additions and 3 deletions

View file

@ -33,7 +33,7 @@ public:
: m_ptr(&ptr)
{
static_assert(
requires { requires typename T::AllowOwnPtr()(); } || !requires(T obj) { requires !typename T::AllowOwnPtr()(); obj.ref(); obj.unref(); },
requires { requires typename T::AllowOwnPtr()(); } || !requires { requires !typename T::AllowOwnPtr()(); declval<T>().ref(); declval<T>().unref(); },
"Use NonnullRefPtr<> for RefCounted types");
}
NonnullOwnPtr(NonnullOwnPtr&& other)

View file

@ -184,8 +184,7 @@ protected:
: m_ptr(ptr)
{
static_assert(
requires { requires typename T::AllowOwnPtr()(); } || !requires(T obj) { requires !typename T::AllowOwnPtr()(); obj.ref(); obj.unref(); },
"Use RefPtr<> for RefCounted types");
requires { requires typename T::AllowOwnPtr()(); } || !requires { requires !typename T::AllowOwnPtr()(); declval<T>().ref(); declval<T>().unref(); }, "Use RefPtr<> for RefCounted types");
}
private: