From 1fac842e24763319f1f32ddf29934dc7ce29ff2a Mon Sep 17 00:00:00 2001 From: Reece Date: Wed, 19 Jan 2022 18:30:57 +0000 Subject: [PATCH] [*] nuked even more of the stl dependency [-] std::forward --- Include/Aurora/Async/WorkBasic.hpp | 4 ++-- Include/Aurora/Console/Logging/ILogger.hpp | 18 +++++++++--------- Include/Aurora/Console/Logging/Logging.hpp | 20 ++++++++++---------- Include/Aurora/Debug/StackTrace.hpp | 2 +- Include/Aurora/Debug/SysErrors.hpp | 4 ++-- Include/Aurora/Debug/SysPanic.hpp | 2 +- Include/AuroraTypedefs.hpp | 14 +++++++++++++- Include/AuroraUtils.hpp | 6 +++--- Source/Crypto/X509/x509.cpp | 2 +- 9 files changed, 42 insertions(+), 30 deletions(-) diff --git a/Include/Aurora/Async/WorkBasic.hpp b/Include/Aurora/Async/WorkBasic.hpp index ee738336..cb0f73a8 100644 --- a/Include/Aurora/Async/WorkBasic.hpp +++ b/Include/Aurora/Async/WorkBasic.hpp @@ -105,7 +105,7 @@ namespace Aurora::Async return DispatchWork, Args...>, ReturnValue_t>(worker, TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), Async::JobFromTupleClazz, Args...>(job), - AuMakeTuple, Args...>(AU_FWD(owner), std::forward(in)...), + AuMakeTuple, Args...>(AU_FWD(owner), AuForward(in)...), false); } @@ -115,7 +115,7 @@ namespace Aurora::Async return DispatchWork, Args...>, ReturnValue_t>(worker, TaskFromTupleCallableWithBindOwner2, Args...>, ReturnValue_t>, ReturnValue_t, FunctorTask_t>(task), Async::JobFromTupleClazzEx, Args...>(success, failure), - AuMakeTuple, Args...>(AU_FWD(owner), std::forward(in)...), + AuMakeTuple, Args...>(AU_FWD(owner), AuForward(in)...), false); } } \ No newline at end of file diff --git a/Include/Aurora/Console/Logging/ILogger.hpp b/Include/Aurora/Console/Logging/ILogger.hpp index 5b056643..2e01e001 100644 --- a/Include/Aurora/Console/Logging/ILogger.hpp +++ b/Include/Aurora/Console/Logging/ILogger.hpp @@ -33,26 +33,26 @@ namespace Aurora::Console::Logging template inline void WriteLinef(AuUInt8 level, const AuString &tag, const AuString &msg, T&& ... args) { - WriteMessage(level, ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, std::forward(args)...))); + WriteMessage(level, ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, AuForward(args)...))); } template inline void WriteLinef(AuUInt8 level, EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args) { - WriteMessage(level, ConsoleMessage(color, tag, fmt::format(msg, std::forward(args)...))); + WriteMessage(level, ConsoleMessage(color, tag, fmt::format(msg, AuForward(args)...))); } template inline void LogVerbose(const AuString &line, T&& ... args) { - WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, AuForward(args)...); } #if defined(STAGING) || defined(DEBUG) template inline void LogVerboseNoShip(const AuString &line, T&& ... args) { - WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, AuForward(args)...); } #else template @@ -68,31 +68,31 @@ namespace Aurora::Console::Logging template inline void LogInfo(const AuString &line, T&& ... args) { - WriteLinef(static_cast(ELogLevel::eInfo), EAnsiColor::eGreen, "Info", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eInfo), EAnsiColor::eGreen, "Info", line, AuForward(args)...); } template inline void LogDbg(const AuString &line, T&& ... args) { - WriteLinef(static_cast(ELogLevel::eDebug), EAnsiColor::eYellow, "Debug", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eDebug), EAnsiColor::eYellow, "Debug", line, AuForward(args)...); } template inline void LogWarn(const AuString &line, T&& ... args) { - WriteLinef(static_cast(ELogLevel::eWarn), EAnsiColor::eRed, "Warn", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eWarn), EAnsiColor::eRed, "Warn", line, AuForward(args)...); } template inline void LogError(const AuString &line, T&& ... args) { - WriteLinef(static_cast(ELogLevel::eError), EAnsiColor::eBoldRed, "Error", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eError), EAnsiColor::eBoldRed, "Error", line, AuForward(args)...); } template inline void LogGame(const AuString &line, T&& ... args) { - WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eBlue, "Game", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eBlue, "Game", line, AuForward(args)...); } #endif }; diff --git a/Include/Aurora/Console/Logging/Logging.hpp b/Include/Aurora/Console/Logging/Logging.hpp index a0ce2059..eabfcb73 100644 --- a/Include/Aurora/Console/Logging/Logging.hpp +++ b/Include/Aurora/Console/Logging/Logging.hpp @@ -18,26 +18,26 @@ namespace Aurora::Console::Logging template static void WriteLinef(const AuString &tag, const AuString &msg, T&& ... args) { - WriteLine(ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, std::forward(args)...))); + WriteLine(ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, AuForward(args)...))); } template static void WriteLinef(EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args) { - WriteLine(ConsoleMessage(color, tag, fmt::format(msg, std::forward(args)...))); + WriteLine(ConsoleMessage(color, tag, fmt::format(msg, AuForward(args)...))); } template static void LogVerbose(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward(args)...); + WriteLinef(EAnsiColor::eYellow, "Verbose", line, AuForward(args)...); } #if defined(STAGING) || defined(DEBUG) template static void LogVerboseNoShip(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward(args)...); + WriteLinef(EAnsiColor::eYellow, "Verbose", line, AuForward(args)...); } #else #define LogVerboseNoShip(...) DoNothing() @@ -51,31 +51,31 @@ namespace Aurora::Console::Logging template static void LogInfo(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eGreen, "Info", line, std::forward(args)...); + WriteLinef(EAnsiColor::eGreen, "Info", line, AuForward(args)...); } template static void LogDbg(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eYellow, "Debug", line, std::forward(args)...); + WriteLinef(EAnsiColor::eYellow, "Debug", line, AuForward(args)...); } template static void LogWarn(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eRed, "Warn", line, std::forward(args)...); + WriteLinef(EAnsiColor::eRed, "Warn", line, AuForward(args)...); } template static void LogError(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eBoldRed, "Error", line, std::forward(args)...); + WriteLinef(EAnsiColor::eBoldRed, "Error", line, AuForward(args)...); } template static void LogGame(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eBlue, "Game", line, std::forward(args)...); + WriteLinef(EAnsiColor::eBlue, "Game", line, AuForward(args)...); } #else @@ -131,7 +131,7 @@ namespace Aurora::Console::Logging template \ static void AuLog ## level(T&& ... args) \ { \ - Aurora::Console::Logging::Log ## level(std::forward(args)...); \ + Aurora::Console::Logging::Log ## level(AuForward(args)...); \ } ADD_AU_GLOBAL_ALIAS(Info) diff --git a/Include/Aurora/Debug/StackTrace.hpp b/Include/Aurora/Debug/StackTrace.hpp index 89c10c82..1fb896e2 100644 --- a/Include/Aurora/Debug/StackTrace.hpp +++ b/Include/Aurora/Debug/StackTrace.hpp @@ -14,7 +14,7 @@ namespace Aurora::Debug AuOptional label; AuUInt64 address; AuOptional module; - AuOptional> file; // file, line, offset + AuOptional> file; // file, line, offset AUKN_SYM AuString Stringify() const; }; diff --git a/Include/Aurora/Debug/SysErrors.hpp b/Include/Aurora/Debug/SysErrors.hpp index 21c86184..a01354d5 100644 --- a/Include/Aurora/Debug/SysErrors.hpp +++ b/Include/Aurora/Debug/SysErrors.hpp @@ -37,7 +37,7 @@ namespace Aurora::Debug static AU_NOINLINE void ErrorMakeNested(const AuString &msg, T&& ... args) _FREECOMPILER_OPTIMIZE_OFF { #if defined(_AUHAS_FMT) - _PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, fmt::format(msg, std::forward(args)...).c_str()); + _PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, fmt::format(msg, AuForward(args)...).c_str()); #else _PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, nullptr); #endif @@ -53,7 +53,7 @@ namespace Aurora::Debug else { #if defined(_AUHAS_FMT) - _PushError(_DBG_RET_ADDR, category, fmt::format(msg, std::forward(args)...).c_str()); + _PushError(_DBG_RET_ADDR, category, fmt::format(msg, AuForward(args)...).c_str()); #else _PushError(_DBG_RET_ADDR, category, "Missing dependency"); #endif diff --git a/Include/Aurora/Debug/SysPanic.hpp b/Include/Aurora/Debug/SysPanic.hpp index 0195cbc8..699640a1 100644 --- a/Include/Aurora/Debug/SysPanic.hpp +++ b/Include/Aurora/Debug/SysPanic.hpp @@ -11,7 +11,7 @@ template static inline void __declspec(noreturn) SysPanic(T... args) { - Aurora::Console::Logging::WriteLinef(Aurora::Console::EAnsiColor::eBoldRed, "Fatal", std::forward(args)...); + Aurora::Console::Logging::WriteLinef(Aurora::Console::EAnsiColor::eBoldRed, "Fatal", AuForward(args)...); Aurora::Debug::Panic(); } #endif \ No newline at end of file diff --git a/Include/AuroraTypedefs.hpp b/Include/AuroraTypedefs.hpp index 13acd8ec..aafd46c2 100644 --- a/Include/AuroraTypedefs.hpp +++ b/Include/AuroraTypedefs.hpp @@ -158,7 +158,6 @@ constexpr AuRemoveReference_t &&AuMove(T &&arg) noexcept return static_cast &&>(arg); } - template struct AuEnableIf { @@ -189,6 +188,19 @@ struct AuConditional template using AuConditional_t = typename AuConditional::type; +template +constexpr T &&AuForward(AuRemoveReference_t &arg) noexcept +{ + return static_cast(arg); +} + +template +constexpr T &&AuForward(AuRemoveReference_t &&arg) noexcept +{ + //static_assert(!is_lvalue_reference_v, "bad forward call"); + return static_cast(arg); +} + #if !defined(AURORA_RUNTIME_AU_LIST) #define AURORA_RUNTIME_AU_LIST std::vector diff --git a/Include/AuroraUtils.hpp b/Include/AuroraUtils.hpp index f2f0b59d..b908686a 100644 --- a/Include/AuroraUtils.hpp +++ b/Include/AuroraUtils.hpp @@ -16,7 +16,7 @@ static auline AuSPtr AuMakeShared(Args&&... args) { try { - return AURORA_RUNTIME_MAKE_SHARED(std::forward(args)...); + return AURORA_RUNTIME_MAKE_SHARED(AuForward(args)...); } catch (...) { @@ -31,7 +31,7 @@ static auline AuSPtr AuMakeShared(Args&&... args) template static auline auto AuMakePair(Args&&... args) { - return AURORA_RUNTIME_MAKE_PAIR(std::forward(args)...); + return AURORA_RUNTIME_MAKE_PAIR(AuForward(args)...); } @@ -42,7 +42,7 @@ static auline auto AuMakePair(Args&&... args) template static auline auto AuMakeTuple(Args&&... args) { - return AURORA_RUNTIME_MAKE_TUPLE(std::forward(args)...); + return AURORA_RUNTIME_MAKE_TUPLE(AuForward(args)...); } diff --git a/Source/Crypto/X509/x509.cpp b/Source/Crypto/X509/x509.cpp index 68328b63..3bc279c8 100644 --- a/Source/Crypto/X509/x509.cpp +++ b/Source/Crypto/X509/x509.cpp @@ -184,7 +184,7 @@ namespace Aurora::Crypto::X509 }) == 0 && ok; } - static int x509_get_crt_ext(mbedtls_x509_crt *crt, const char *oid, int oidLength, std::function cb) + static int x509_get_crt_ext(mbedtls_x509_crt *crt, const char *oid, int oidLength, AuFunction cb) { int ret = 0; size_t len;