ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.8 by root, Mon Sep 11 23:33:30 2006 UTC vs.
Revision 1.9 by root, Tue Sep 12 18:15:34 2006 UTC

116template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } 116template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; }
117template<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; } 117template<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
119template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } 119template<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
122template<int N>
123inline 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines