diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index 13975f056..607c4522b 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -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 inline T clamp(T a, T l, T u) + template inline T clamp(T val, T lower, T upper) { - return (au) ? u : a; + return (val < lower) ? lower : (val > upper) ? upper : val; + } + template inline void clamp(T& val, T lower, T upper, T setVal) + { + if(val < lower || val > upper) val = setVal; } // Compare two strings, ignoring case