From a410e2048db6f5ef6fb50e401a59b4b98b979050 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 4 Apr 2019 17:12:25 +0800 Subject: ... --- src/util/math_util.hpp | 51 -------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/util/math_util.hpp (limited to 'src/util/math_util.hpp') diff --git a/src/util/math_util.hpp b/src/util/math_util.hpp deleted file mode 100644 index 01348641..00000000 --- a/src/util/math_util.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once -#include "pre.hpp" - -#include -#include - -namespace cru::util { -template >> -float Coerce(const T n, const std::optional min, - const std::optional max) { - if (min.has_value() && n < min.value()) return min.value(); - if (max.has_value() && n > max.value()) return max.value(); - return n; -} - -template >> -float Coerce(const T n, const T min, const T max) { - if (n < min) return min; - if (n > max) return max; - return n; -} - -template >> -float Coerce(const T n, const std::nullopt_t, const std::optional max) { - if (max.has_value() && n > max.value()) return max.value(); - return n; -} - -template >> -float Coerce(const T n, const std::optional min, const std::nullopt_t) { - if (min.has_value() && n < min.value()) return min.value(); - return n; -} - -template >> -float Coerce(const T n, const std::nullopt_t, const T max) { - if (n > max) return max; - return n; -} - -template >> -float Coerce(const T n, const T min, const std::nullopt_t) { - if (n < min) return min; - return n; -} - -template >> -T AtLeast0(const T value) { - return value < static_cast(0) ? static_cast(0) : value; -} -} // namespace cru::util -- cgit v1.2.3