mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-17 01:10:28 +03:00
AK: Add formatters for NonnullOwnPtr and WeakPtr.
This commit is contained in:
parent
0508fdbbcd
commit
235622dc7f
Notes:
sideshowbarker
2024-07-19 01:52:30 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/235622dc7f7 Pull-request: https://github.com/SerenityOS/serenity/pull/3776 Reviewed-by: https://github.com/alimpfard
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user