diff --git a/AK/Format.h b/AK/Format.h index 48682c2dbe..c52932e974 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -39,6 +39,9 @@ inline constexpr bool HasFormatter = true; template inline constexpr bool HasFormatter::__no_formatter_defined> = false; +template +concept Formattable = HasFormatter; + constexpr size_t max_format_arguments = 256; struct TypeErasedParameter { diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index 069ac05c85..a862878867 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -228,7 +228,16 @@ inline NonnullRefPtr adopt_ref(T& object) return NonnullRefPtr(NonnullRefPtr::Adopt, object); } +template +struct Formatter> : Formatter { + ErrorOr format(FormatBuilder& builder, NonnullRefPtr const& value) + { + return Formatter::format(builder, *value); + } +}; + template +requires(!HasFormatter) struct Formatter> : Formatter { ErrorOr format(FormatBuilder& builder, NonnullRefPtr const& value) {