mirror of https://github.com/stella-emu/stella.git
Introduce another version of BSPF::clamp.
This commit is contained in:
parent
369c426f33
commit
ace146fe52
|
@ -111,9 +111,13 @@ namespace BSPF
|
||||||
|
|
||||||
// Combines 'max' and 'min', and clamps value to the upper/lower value
|
// Combines 'max' and 'min', and clamps value to the upper/lower value
|
||||||
// if it is outside the specified range
|
// 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
|
// Compare two strings, ignoring case
|
||||||
|
|
Loading…
Reference in New Issue