summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-08-24 10:45:12 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-08-25 11:47:59 +0200
commit65e895dfb662c3fd87e37628358f3bd955eb4b5f (patch)
treea803449e42af38bdee81a65b142367428e0ce437
parent87a72de7359ad89246791169a842c8de9d0c9498 (diff)
compat/util: use std::decay for overload resolution
-rw-r--r--compat/util.hpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/compat/util.hpp b/compat/util.hpp
index 59c270ed..5a7ccd86 100644
--- a/compat/util.hpp
+++ b/compat/util.hpp
@@ -46,7 +46,7 @@ inline auto clamp_float(n val, n min, n max)
return std::fmin(std::fmax(val, min), max);
}
-template<typename n>
+template<typename t, typename n>
struct clamp final
{
static inline auto clamp_(const n& val, const n& min, const n& max)
@@ -59,8 +59,8 @@ struct clamp final
}
};
-template<>
-struct clamp<float>
+template<typename t>
+struct clamp<float, t>
{
static inline auto clamp_(float val, float min, float max)
{
@@ -68,8 +68,8 @@ struct clamp<float>
}
};
-template<>
-struct clamp<double>
+template<typename t>
+struct clamp<double, t>
{
static inline auto clamp_(double val, double min, double max)
{
@@ -83,5 +83,5 @@ template<typename t, typename u, typename w>
inline auto clamp(const t& val, const u& min, const w& max)
{
using tp = decltype(val + min + max);
- return ::util_detail::clamp<tp>::clamp_(val, min, max);
+ return ::util_detail::clamp<std::decay_t<tp>, tp>::clamp_(val, min, max);
}