AK: Add formatters for NonnullOwnPtr and WeakPtr.

This commit is contained in:
asynts 2020-10-15 15:24:01 +02:00 committed by Andreas Kling
parent 0508fdbbcd
commit 235622dc7f
Notes: sideshowbarker 2024-07-19 01:52:30 +09:00
2 changed files with 16 additions and 0 deletions

View File

@ -193,6 +193,14 @@ inline void swap(NonnullOwnPtr<T>& a, NonnullOwnPtr<U>& b)
a.swap(b);
}
template<typename T>
struct Formatter<NonnullOwnPtr<T>> : Formatter<const T*> {
void format(TypeErasedFormatParams& params, FormatBuilder& builder, const NonnullOwnPtr<T>& value)
{
Formatter<const T*>::format(params, builder, value.ptr());
}
};
}
using AK::adopt_own;

View File

@ -102,6 +102,14 @@ inline const LogStream& operator<<(const LogStream& stream, const WeakPtr<T>& va
return stream << value.ptr();
}
template<typename T>
struct Formatter<WeakPtr<T>> : Formatter<const T*> {
void format(TypeErasedFormatParams& params, FormatBuilder& builder, const WeakPtr<T>& value)
{
Formatter<const T*>::format(params, builder, value.ptr());
}
};
}
using AK::WeakPtr;