Introduce another version of BSPF::clamp.

This commit is contained in:
Stephen Anthony 2017-08-02 15:26:48 -02:30
parent 369c426f33
commit ace146fe52
1 changed files with 6 additions and 2 deletions

View File

@ -111,9 +111,13 @@ namespace BSPF
// Combines 'max' and 'min', and clamps value to the upper/lower value
// if it is outside the specified range
template<typename T> inline T clamp(T a, T l, T u)
template<class T> inline T clamp(T val, T lower, T upper)
{
return (a<l) ? l : (a>u) ? u : a;
return (val < lower) ? lower : (val > upper) ? upper : val;
}
template<class T> inline void clamp(T& val, T lower, T upper, T setVal)
{
if(val < lower || val > upper) val = setVal;
}
// Compare two strings, ignoring case