mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 21:15:14 +00:00
AK: Make String compile on platforms where size_t==u32
This kind of thing is a bit annoying. On Serenity, size_t is the same size as u32, but not the same type. Because of "long" or whatever. This patch makes String not complain about duplicate overloads.
This commit is contained in:
parent
749e3f0f30
commit
a7f538fb63
Notes:
sideshowbarker
2024-07-19 11:46:04 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a7f538fb637
2 changed files with 18 additions and 7 deletions
|
@ -184,17 +184,21 @@ unsigned String::to_uint(bool& ok) const
|
|||
return value;
|
||||
}
|
||||
|
||||
String String::number(size_t value)
|
||||
String String::number(u64 value)
|
||||
{
|
||||
return String::format("%zu", value);
|
||||
#ifdef __serenity__
|
||||
return String::format("%Q", value);
|
||||
#else
|
||||
return String::format("%llu", value);
|
||||
#endif
|
||||
}
|
||||
|
||||
String String::number(unsigned value)
|
||||
String String::number(u32 value)
|
||||
{
|
||||
return String::format("%u", value);
|
||||
}
|
||||
|
||||
String String::number(int value)
|
||||
String String::number(i32 value)
|
||||
{
|
||||
return String::format("%d", value);
|
||||
}
|
||||
|
|
13
AK/String.h
13
AK/String.h
|
@ -194,9 +194,16 @@ public:
|
|||
}
|
||||
|
||||
static String format(const char*, ...);
|
||||
static String number(size_t);
|
||||
static String number(unsigned);
|
||||
static String number(int);
|
||||
static String number(u64);
|
||||
static String number(u32);
|
||||
static String number(i32);
|
||||
|
||||
#ifdef __serenity__
|
||||
static String number(size_t n)
|
||||
{
|
||||
return number((u32)n);
|
||||
}
|
||||
#endif
|
||||
|
||||
StringView view() const { return { characters(), length() }; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue