mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
AK: Format the contents of NNRP<T> if T is formattable
This commit is contained in:
parent
ff038f306a
commit
08fc42002c
Notes:
sideshowbarker
2024-07-17 03:25:57 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/08fc42002c Pull-request: https://github.com/SerenityOS/serenity/pull/16396 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling ✅
@ -39,6 +39,9 @@ inline constexpr bool HasFormatter = true;
|
||||
template<typename T>
|
||||
inline constexpr bool HasFormatter<T, typename Formatter<T>::__no_formatter_defined> = false;
|
||||
|
||||
template<typename T>
|
||||
concept Formattable = HasFormatter<T>;
|
||||
|
||||
constexpr size_t max_format_arguments = 256;
|
||||
|
||||
struct TypeErasedParameter {
|
||||
|
@ -228,7 +228,16 @@ inline NonnullRefPtr<T> adopt_ref(T& object)
|
||||
return NonnullRefPtr<T>(NonnullRefPtr<T>::Adopt, object);
|
||||
}
|
||||
|
||||
template<Formattable T>
|
||||
struct Formatter<NonnullRefPtr<T>> : Formatter<T> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, NonnullRefPtr<T> const& value)
|
||||
{
|
||||
return Formatter<T>::format(builder, *value);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
requires(!HasFormatter<T>)
|
||||
struct Formatter<NonnullRefPtr<T>> : Formatter<T const*> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, NonnullRefPtr<T> const& value)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user