From 9aab67fed816c5424cd63907e01e8da8ce4d1e6b Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 22 Feb 2023 01:17:56 +0200 Subject: [PATCH] BAN: make all Math functions inline constexpr --- BAN/include/BAN/Math.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/BAN/include/BAN/Math.h b/BAN/include/BAN/Math.h index 30931ff3..933bfdac 100644 --- a/BAN/include/BAN/Math.h +++ b/BAN/include/BAN/Math.h @@ -2,29 +2,31 @@ #include +#include + namespace BAN::Math { template - T min(T a, T b) + inline constexpr T min(T a, T b) { return a < b ? a : b; } template - T max(T a, T b) + inline constexpr T max(T a, T b) { return a > b ? a : b; } template - T clamp(T x, T min, T max) + inline constexpr T clamp(T x, T min, T max) { return x < min ? min : x > max ? max : x; } template - T gcd(T a, T b) + inline constexpr T gcd(T a, T b) { T t; while (b) @@ -37,13 +39,13 @@ namespace BAN::Math } template - T lcm(T a, T b) + inline constexpr T lcm(T a, T b) { return a / gcd(a, b) * b; } template - T div_round_up(T a, T b) + inline constexpr T div_round_up(T a, T b) { return (a + b - 1) / b; }