mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Piggyback: AK: Add formatter for std::nullptr_t.
This commit is contained in:
parent
4cfef0cd95
commit
632ff01e17
11
AK/Format.h
11
AK/Format.h
|
@ -348,6 +348,17 @@ struct Formatter<double> : StandardFormatter {
|
|||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct Formatter<std::nullptr_t> : Formatter<FlatPtr> {
|
||||
void format(FormatBuilder& builder, std::nullptr_t)
|
||||
{
|
||||
if (m_mode == Mode::Default)
|
||||
m_mode = Mode::Pointer;
|
||||
|
||||
return Formatter<FlatPtr>::format(builder, 0);
|
||||
}
|
||||
};
|
||||
|
||||
void vformat(StringBuilder& builder, StringView fmtstr, TypeErasedFormatParams);
|
||||
void vformat(const LogStream& stream, StringView fmtstr, TypeErasedFormatParams);
|
||||
|
||||
|
|
|
@ -269,4 +269,9 @@ TEST_CASE(yay_this_implementation_sucks)
|
|||
EXPECT_EQ(String::formatted("{:.0}", .99999999999), "0.");
|
||||
}
|
||||
|
||||
TEST_CASE(format_nullptr)
|
||||
{
|
||||
EXPECT_EQ(String::formatted("{}", nullptr), String::formatted("{:p}", static_cast<FlatPtr>(0)));
|
||||
}
|
||||
|
||||
TEST_MAIN(Format)
|
||||
|
|
Loading…
Reference in a new issue