diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-09 17:45:11 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-09 17:51:21 +0100 |
commit | 1726c17d0d4325f11124e270ae1658110af606d0 (patch) | |
tree | 4ff7efc00b95a10e1e90413dbbc91e8fb0cf0659 /AK | |
parent | 91fc6a056b61c1c7aba3bf3a4f0df9dcec91a836 (diff) | |
download | serenity-1726c17d0d4325f11124e270ae1658110af606d0.zip |
AK: Handle LogStream operator<<(size_t)
This has been an annoyingly missing feature for some time.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/LogStream.cpp | 9 | ||||
-rw-r--r-- | AK/LogStream.h | 17 |
2 files changed, 22 insertions, 4 deletions
diff --git a/AK/LogStream.cpp b/AK/LogStream.cpp index cf093b0dfa..912c90b412 100644 --- a/AK/LogStream.cpp +++ b/AK/LogStream.cpp @@ -16,12 +16,17 @@ const LogStream& operator<<(const LogStream& stream, const StringView& value) return stream; } -const LogStream& operator<<(const LogStream& stream, int value) +const LogStream& operator<<(const LogStream& stream, i32 value) { return stream << String::number(value); } -const LogStream& operator<<(const LogStream& stream, unsigned value) +const LogStream& operator<<(const LogStream& stream, u32 value) +{ + return stream << String::number(value); +} + +const LogStream& operator<<(const LogStream& stream, u64 value) { return stream << String::number(value); } diff --git a/AK/LogStream.h b/AK/LogStream.h index 55f7132278..fd311523a3 100644 --- a/AK/LogStream.h +++ b/AK/LogStream.h @@ -1,5 +1,6 @@ #pragma once +#include <AK/Types.h> #include <AK/kstdio.h> #ifdef USERLAND @@ -59,8 +60,20 @@ inline const LogStream& operator<<(const LogStream& stream, const char* value) const LogStream& operator<<(const LogStream&, const String&); const LogStream& operator<<(const LogStream&, const StringView&); -const LogStream& operator<<(const LogStream&, int); -const LogStream& operator<<(const LogStream&, unsigned); +const LogStream& operator<<(const LogStream&, i32); +const LogStream& operator<<(const LogStream&, u32); +const LogStream& operator<<(const LogStream&, u64); + +#ifdef __serenity__ +inline const LogStream& operator<<(const LogStream& stream, size_t value) +{ + if constexpr (sizeof(size_t) == 4) + return stream << (u32)value; + else + return stream << (u64)value; +} +#endif + const LogStream& operator<<(const LogStream&, const void*); inline const LogStream& operator<<(const LogStream& stream, char value) |