- clamp(): Remove definition in compat.h and uplift definition in templates.h.

This commit is contained in:
Mitchell Richters 2020-10-06 21:14:25 +11:00
parent 8be8bcc87a
commit 90e711464a
2 changed files with 4 additions and 5 deletions

View file

@ -189,7 +189,6 @@ static FORCE_INLINE uint16_t B_UNBUF16(void const * const buf) { return *(uint16
////////// Abstract data operations //////////
template <typename T, typename X, typename Y> constexpr T clamp(T in, X min, Y max) { return in <= (T) min ? (T) min : (in >= (T) max ? (T) max : in); }
using std::min;
using std::max;

View file

@ -136,11 +136,11 @@ const T MAX (const T a, const T b)
// Clamps in to the range [min,max].
//==========================================================================
template<class T>
inline
T clamp (const T in, const T min, const T max)
template<typename T, typename X, typename Y>
inline constexpr
T clamp (const T in, const X min, const Y max)
{
return in <= min ? min : in >= max ? max : in;
return in <= (T) min ? (T) min : in >= (T) max ? (T) max : in;
}
#endif //__TEMPLATES_H__