aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/util.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index 83ba73c30f..c55bee6c1d 100644
--- a/common/util.h
+++ b/common/util.h
@@ -37,6 +37,8 @@
template<typename T> inline T ABS (T x) { return (x>=0) ? x : -x; }
template<typename T> inline T MIN (T a, T b) { return (a<b) ? a : b; }
template<typename T> inline T MAX (T a, T b) { return (a>b) ? a : b; }
+template<typename T> inline T CLIP (T v, T amin, T amax)
+ { if (v < amin) return amin; else if (v > amax) return amax; else return v; }
/**
* Template method which swaps the vaulues of its two parameters.