--- a/sources/basics.h Wed Jan 27 12:38:00 2021 +0200 +++ b/sources/basics.h Wed Jan 27 13:02:51 2021 +0200 @@ -29,6 +29,7 @@ */ #pragma once +#include <type_traits> #include <stdlib.h> #if !defined(_MSC_VER) && !defined(__cdecl) @@ -106,8 +107,8 @@ return result; } -template<typename T> -T clamp (T a, T b, T c) +template<typename T, typename TT, typename TTT> +std::common_type_t<T, TT, TTT> clamp(T a, TT b, TTT c) { return (a < b) ? b : (a > c) ? c : a; }