From d4d799cac8080d4066394f338c31611ae655d5f6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 26 Sep 2021 20:56:25 +0200 Subject: compat: use std::clamp, remove own version --- compat/correlation-calibrator.cpp | 2 +- compat/math.hpp | 48 --------------------------------------- 2 files changed, 1 insertion(+), 49 deletions(-) (limited to 'compat') diff --git a/compat/correlation-calibrator.cpp b/compat/correlation-calibrator.cpp index 01f3b14f..08fbcaa7 100644 --- a/compat/correlation-calibrator.cpp +++ b/compat/correlation-calibrator.cpp @@ -49,7 +49,7 @@ bool correlation_calibrator::check_buckets(const vec6& data) for (unsigned k = 0; k < 6; k++) { - const double val = clamp(data[k], min[k], max[k]); + const double val = std::clamp(data[k], min[k], max[k]); pos[k] = unsigned((val-min[k])/spacing[k]); if (pos[k] >= nbuckets[k]) diff --git a/compat/math.hpp b/compat/math.hpp index 34428cbd..1387324e 100644 --- a/compat/math.hpp +++ b/compat/math.hpp @@ -5,54 +5,6 @@ #include #include -namespace util_detail { - -template -inline auto clamp_float(n val, n min_, n max_) -{ - return std::fmin(std::fmax(val, min_), max_); -} - -template -struct clamp final -{ - static inline auto clamp_(t val, t min_, t max_) - { - if (unlikely(val > max_)) - return max_; - if (unlikely(val < min_)) - return min_; - return val; - } -}; - -template<> -struct clamp -{ - static inline auto clamp_(float val, float min_, float max_) - { - return clamp_float(val, min_, max_); - } -}; - -template<> -struct clamp -{ - static inline auto clamp_(double val, double min_, double max_) - { - return clamp_float(val, min_, max_); - } -}; - -} // ns util_detail - -template -inline auto clamp(const t& val, const u& min, const v& max) -{ - using w = cv_qualified; - return util_detail::clamp::clamp_(val, min, max); -} - template inline auto iround(t val) -> std::enable_if_t>, int> { -- cgit v1.2.3