Skip to content

Commit

Permalink
AK: Make (Nonnull)OwnPtr work with abstract classes
Browse files Browse the repository at this point in the history
Clang produced a compile error at this requires statement if `T` was an
abstract class.
  • Loading branch information
BertalanD authored and alimpfard committed Jul 2, 2021
1 parent b97a00d commit 3162c9e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion AK/NonnullOwnPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NonnullOwnPtr {
: 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)
Expand Down
3 changes: 1 addition & 2 deletions AK/OwnPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ class OwnPtr {
: 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:
Expand Down

0 comments on commit 3162c9e

Please sign in to comment.