… | |
… | |
116 | template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } |
116 | template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } |
117 | template<typename T, typename U, typename V> static inline T clamp (T v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; } |
117 | template<typename T, typename U, typename V> static inline T clamp (T v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; } |
118 | |
118 | |
119 | template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } |
119 | template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } |
120 | |
120 | |
|
|
121 | // basically does what strncpy should do |
|
|
122 | template<int N> |
|
|
123 | inline void assign (char (&dst)[N], const char *src) |
|
|
124 | { |
|
|
125 | // should be optimised at some point, maybe should also add "..." |
|
|
126 | // when buffer is too small. |
|
|
127 | snprintf (dst, N, "%s", src); |
|
|
128 | } |
|
|
129 | |
121 | #endif |
130 | #endif |
122 | |
131 | |