--- gvpe/src/global.h 2008/08/07 17:54:27 1.24 +++ gvpe/src/global.h 2011/03/06 21:01:37 1.25 @@ -82,5 +82,14 @@ extern char *confbase; // directory in which all config files are extern char *thisnode; // config for current node (TODO: remove) +template static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } +template static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } +template static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } +template static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } + +template static inline T clamp (T v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; } + +template static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } + #endif