From 1c0822e573f3add0510a6357f6f099474d83ad02 Mon Sep 17 00:00:00 2001 From: MineRobber9000 Date: Sat, 19 Sep 2026 18:05:44 -0400 Subject: [PATCH] Replace Math::Min and Math::Max overloads with templated definition This should prevent type ambiguity issues in the 3DS build, hopefully. --- cpp/core/CS_Math.h | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/cpp/core/CS_Math.h b/cpp/core/CS_Math.h index a73798f..cfe11a6 100644 --- a/cpp/core/CS_Math.h +++ b/cpp/core/CS_Math.h @@ -14,39 +14,17 @@ namespace MiniScript { // Static Math class - equivalent to C# Math class Math { public: - // Min functions - equivalent to C# Math.Min - static int32_t Min(int32_t a, int32_t b) { - return std::min(a, b); - } - - static int64_t Min(int64_t a, int64_t b) { - return std::min(a, b); - } - - static float Min(float a, float b) { - return std::min(a, b); - } - - static double Min(double a, double b) { - return std::min(a, b); - } - - // Max functions - equivalent to C# Math.Max - static int32_t Max(int32_t a, int32_t b) { - return std::max(a, b); - } - - static int64_t Max(int64_t a, int64_t b) { - return std::max(a, b); - } - - static float Max(float a, float b) { - return std::max(a, b); - } - - static double Max(double a, double b) { - return std::max(a, b); - } + template + static auto Min(T a, U b) { + using Common = typename std::common_type::type; + return std::min(static_cast(a), static_cast(b)); + } + + template + static auto Max(T a, U b) { + using Common = typename std::common_type::type; + return std::max(static_cast(a), static_cast(b)); + } static double Round(double x) { return std::round(x);