From a16b56325d42af756dd64b71be07c36123b03993 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 20 Apr 2021 22:08:57 -0500 Subject: [PATCH] [ox/std] Remove unnecessary template parameters from assert functions --- deps/ox/src/ox/std/assert.cpp | 12 +++++------- deps/ox/src/ox/std/assert.hpp | 14 ++++---------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index f6583da6..4fa99e4a 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -17,8 +17,7 @@ namespace ox { -template<> -void assertFunc([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]bool pass, [[maybe_unused]]const char *msg) noexcept { +void assertFunc([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]bool pass, [[maybe_unused]]const char *msg) noexcept { if (!pass) { #if defined(OX_USE_STDLIB) std::cerr << "\033[31;1;1mASSERT FAILURE:\033[0m (" << file << ':' << line << "): " << msg << std::endl; @@ -31,8 +30,7 @@ void assertFunc([[maybe_unused]]const char *file, [[maybe_unused]]int line } } -template<> -void assertFunc(const char *file, int line, Error err, const char *assertMsg) noexcept { +void assertFunc(const char *file, int line, const Error &err, const char *assertMsg) noexcept { if (err) { #if defined(OX_USE_STDLIB) std::cerr << "\033[31;1;1mASSERT FAILURE:\033[0m (" << file << ':' << line << "): " << assertMsg << '\n'; @@ -41,7 +39,7 @@ void assertFunc(const char *file, int line, Error err, const char *assert } std::cerr << "\tError Code:\t" << err << '\n'; if (err.file != nullptr) { - std::cerr << "\tError Location:\t" << reinterpret_cast(err.file) << ':' << err.line << '\n'; + std::cerr << "\tError Location:\t" << err.file << ':' << err.line << '\n'; } printStackTrace(2); oxTrace("panic").del("") << "Panic: " << assertMsg << " (" << file << ":" << line << ")"; @@ -53,14 +51,14 @@ void assertFunc(const char *file, int line, Error err, const char *assert } #if defined(OX_USE_STDLIB) -void panic(const char *file, int line, const char *panicMsg, Error err) noexcept { +void panic(const char *file, int line, const char *panicMsg, const Error &err) noexcept { std::cerr << "\033[31;1;1mPANIC:\033[0m (" << file << ':' << line << "): " << panicMsg << '\n'; if (err.msg) { std::cerr << "\tError Message:\t" << err.msg << '\n'; } std::cerr << "\tError Code:\t" << err << '\n'; if (err.file != nullptr) { - std::cerr << "\tError Location:\t" << reinterpret_cast(err.file) << ':' << err.line << '\n'; + std::cerr << "\tError Location:\t" << err.file << ':' << err.line << '\n'; } printStackTrace(2); oxTrace("panic").del("") << "Panic: " << panicMsg << " (" << file << ":" << line << ")"; diff --git a/deps/ox/src/ox/std/assert.hpp b/deps/ox/src/ox/std/assert.hpp index e1ef7862..f15e63a4 100644 --- a/deps/ox/src/ox/std/assert.hpp +++ b/deps/ox/src/ox/std/assert.hpp @@ -13,23 +13,17 @@ namespace ox { -template -void assertFunc(const char*, int, T, const char*) noexcept { -} +void assertFunc(const char *file, int line, bool pass, const char *msg) noexcept; -template<> -void assertFunc(const char *file, int line, bool pass, const char *msg) noexcept; +void assertFunc(const char *file, int line, const Error &err, const char *msg) noexcept; -template<> -void assertFunc(const char *file, int line, Error err, const char*) noexcept; - -void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]const char *msg, [[maybe_unused]]Error err = OxError(0)) noexcept; +void panic([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]const char *msg, [[maybe_unused]]const Error &err = OxError(0)) noexcept; } #define oxPanic(errCode, msg) ox::panic(__FILE__, __LINE__, msg, errCode) #ifndef NDEBUG -#define oxAssert(pass, msg) ox::assertFunc(__FILE__, __LINE__, pass, msg) +#define oxAssert(pass, msg) ox::assertFunc(__FILE__, __LINE__, pass, msg) #else inline void oxAssert(bool, const char*) {} inline void oxAssert(ox::Error, const char*) {}