mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Allow calling format without arguments.
This commit is contained in:
parent
ed5407a3d7
commit
3224fb7d55
Notes:
sideshowbarker
2024-07-19 02:15:52 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/3224fb7d55e Pull-request: https://github.com/SerenityOS/serenity/pull/3587
2 changed files with 7 additions and 2 deletions
|
@ -96,13 +96,13 @@ struct Formatter<T, typename EnableIf<IsIntegral<T>::value>::Type> {
|
|||
template<typename... Parameters>
|
||||
String format(StringView fmtstr, const Parameters&... parameters)
|
||||
{
|
||||
Array formatters { Detail::Format::make_type_erased_formatter(parameters)... };
|
||||
Array<Detail::Format::TypeErasedFormatter, sizeof...(parameters)> formatters { Detail::Format::make_type_erased_formatter(parameters)... };
|
||||
return Detail::Format::format(fmtstr, formatters);
|
||||
}
|
||||
template<typename... Parameters>
|
||||
void format(StringBuilder& builder, StringView fmtstr, const Parameters&... parameters)
|
||||
{
|
||||
Array formatters { Detail::Format::make_type_erased_formatter(parameters)... };
|
||||
Array<Detail::Format::TypeErasedFormatter, sizeof...(parameters)> formatters { Detail::Format::make_type_erased_formatter(parameters)... };
|
||||
Detail::Format::format(builder, fmtstr, formatters);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,4 +74,9 @@ TEST_CASE(string_builder)
|
|||
EXPECT_EQ(builder.to_string(), " 42 21 ");
|
||||
}
|
||||
|
||||
TEST_CASE(format_without_arguments)
|
||||
{
|
||||
EXPECT_EQ(AK::format("foo"), "foo");
|
||||
}
|
||||
|
||||
TEST_MAIN(Format)
|
||||
|
|
Loading…
Reference in a new issue