#pragma once // ReSharper disable once CppUnusedIncludeDirective #include "pre.hpp" // ReSharper disable once CppUnusedIncludeDirective #include #include namespace cru { 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; } }