mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
AK: Move String::number entirely to header file
Use SFINAE to enforce the fact that it's supposed to only be called for Arithmetic types, rather than counting on the linker to tell us that an instantiation of String::number(my_arg) was not found. This also adds String::number for floating point types as a side-effect.
This commit is contained in:
parent
b4eb734204
commit
0c51778510
Notes:
sideshowbarker
2024-07-19 00:24:14 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/0c51778510a Pull-request: https://github.com/SerenityOS/serenity/pull/4646
2 changed files with 2 additions and 17 deletions
|
@ -239,21 +239,6 @@ template Optional<u16> String::to_uint() const;
|
|||
template Optional<u32> String::to_uint() const;
|
||||
template Optional<u64> String::to_uint() const;
|
||||
|
||||
template<typename T>
|
||||
String String::number(T value) { return formatted("{}", value); }
|
||||
|
||||
template String String::number(unsigned char);
|
||||
template String String::number(unsigned short);
|
||||
template String String::number(unsigned int);
|
||||
template String String::number(unsigned long);
|
||||
template String String::number(unsigned long long);
|
||||
template String String::number(char);
|
||||
template String String::number(short);
|
||||
template String String::number(int);
|
||||
template String String::number(long);
|
||||
template String String::number(long long);
|
||||
template String String::number(signed char);
|
||||
|
||||
String String::format(const char* fmt, ...)
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
|
|
@ -252,8 +252,8 @@ public:
|
|||
return vformatted(fmtstr, VariadicFormatParams { parameters... });
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static String number(T);
|
||||
template<typename T, typename EnableIf<IsArithmetic<T>::value>::Type* = nullptr>
|
||||
static String number(T value) { return formatted("{}", value); }
|
||||
|
||||
StringView view() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue