From 5a449cb40b14a5e59376c9853af9e07c9e37bcfe Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 30 May 2021 15:57:27 -0500 Subject: [PATCH] [ox/std] Remove template integer operators from OutStream --- deps/ox/src/ox/std/trace.hpp | 114 +++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 38 deletions(-) diff --git a/deps/ox/src/ox/std/trace.hpp b/deps/ox/src/ox/std/trace.hpp index 16bd1b68..ab57024a 100644 --- a/deps/ox/src/ox/std/trace.hpp +++ b/deps/ox/src/ox/std/trace.hpp @@ -102,20 +102,25 @@ class OutStream { oxTraceHook(m_msg.file, m_msg.line, m_msg.ch, m_msg.msg.c_str()); } - template - constexpr OutStream &operator<<(const typename enable_if>::type &v) noexcept { - if (m_msg.msg.len()) { - m_msg.msg += m_delimiter; - } - if constexpr(T(-1) < 0) { - m_msg.msg += static_cast(v); - } else { - m_msg.msg += static_cast(v); - } - return *this; - } + constexpr OutStream &operator<<(short v) noexcept; - constexpr OutStream &operator<<(char *v) noexcept { + constexpr OutStream &operator<<(int v) noexcept; + + constexpr OutStream &operator<<(long v) noexcept; + + constexpr OutStream &operator<<(long long v) noexcept; + + constexpr OutStream &operator<<(unsigned char v) noexcept; + + constexpr OutStream &operator<<(unsigned short v) noexcept; + + constexpr OutStream &operator<<(unsigned int v) noexcept; + + constexpr OutStream &operator<<(unsigned long v) noexcept; + + constexpr OutStream &operator<<(unsigned long long v) noexcept; + + constexpr OutStream &operator<<(char v) noexcept { if (m_msg.msg.len()) { m_msg.msg += m_delimiter; } @@ -132,37 +137,17 @@ class OutStream { } template - constexpr OutStream &operator<<(const BasicString &v) noexcept { - if (m_msg.msg.len()) { - m_msg.msg += m_delimiter; - } - m_msg.msg += v.c_str(); - return *this; + constexpr OutStream &operator<<(const BString &v) noexcept { + return operator<<(v.c_str()); } template - constexpr OutStream &operator<<(const BString &v) noexcept { - if (m_msg.msg.len()) { - m_msg.msg += m_delimiter; - } - m_msg.msg += v.c_str(); - return *this; - } - - constexpr OutStream &operator<<(char v) noexcept { - if (m_msg.msg.len()) { - m_msg.msg += m_delimiter; - } - m_msg.msg += v; - return *this; + constexpr OutStream &operator<<(const BasicString &v) noexcept { + return operator<<(v.c_str()); } constexpr OutStream &operator<<(const Error &err) noexcept { - if (m_msg.msg.len()) { - m_msg.msg += m_delimiter; - } - m_msg.msg += static_cast(err); - return *this; + return appendSignedInt(static_cast(err)); } /** @@ -173,8 +158,61 @@ class OutStream { return *this; } + private: + constexpr OutStream &appendSignedInt(int64_t v) noexcept { + if (m_msg.msg.len()) { + m_msg.msg += m_delimiter; + } + m_msg.msg += static_cast(v); + return *this; + } + + constexpr OutStream &appendUnsignedInt(uint64_t v) noexcept { + if (m_msg.msg.len()) { + m_msg.msg += m_delimiter; + } + m_msg.msg += static_cast(v); + return *this; + } + }; +constexpr OutStream &OutStream::operator<<(short v) noexcept { + return appendSignedInt(v); +} + +constexpr OutStream &OutStream::operator<<(int v) noexcept { + return appendSignedInt(v); +} + +constexpr OutStream &OutStream::operator<<(long v) noexcept { + return appendSignedInt(v); +} + +constexpr OutStream &OutStream::operator<<(long long v) noexcept { + return appendSignedInt(v); +} + +constexpr OutStream &OutStream::operator<<(unsigned char v) noexcept { + return appendUnsignedInt(v); +} + +constexpr OutStream &OutStream::operator<<(unsigned short v) noexcept { + return appendUnsignedInt(v); +} + +constexpr OutStream &OutStream::operator<<(unsigned int v) noexcept { + return appendUnsignedInt(v); +} + +constexpr OutStream &OutStream::operator<<(unsigned long v) noexcept { + return appendUnsignedInt(v); +} + +constexpr OutStream &OutStream::operator<<(unsigned long long v) noexcept { + return appendUnsignedInt(v); +} + class NullStream {