1 | #ifndef RXVT_UTIL_H |
1 | #ifndef RXVT_UTIL_H |
2 | #define RXVT_UTIL_H |
2 | #define RXVT_UTIL_H |
3 | |
3 | |
4 | #include <new> |
|
|
5 | #include <stdlib.h> |
4 | #include <stdlib.h> |
6 | #include <string.h> |
5 | #include <string.h> |
7 | #include "ecb.h" |
6 | #include "ecb.h" |
8 | #include "estl.h" |
7 | #include "estl.h" |
9 | |
8 | |
… | |
… | |
22 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
21 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
23 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
22 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
24 | |
23 | |
25 | 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; } |
24 | 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; } |
26 | template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = v < (T)a ? a : v >(T)b ? b : v; } |
25 | template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = v < (T)a ? a : v >(T)b ? b : v; } |
27 | |
|
|
28 | template<typename T> static inline T squared_diff (T a, T b) { return (a - b) * (a - b); } |
|
|
29 | |
26 | |
30 | // linear interpolation |
27 | // linear interpolation |
31 | template<typename T, typename U, typename P> |
28 | template<typename T, typename U, typename P> |
32 | static inline T |
29 | static inline T |
33 | lerp (T a, U b, P p) |
30 | lerp (T a, U b, P p) |
… | |
… | |
61 | { |
58 | { |
62 | void *operator new (size_t s); |
59 | void *operator new (size_t s); |
63 | void operator delete (void *p, size_t s); |
60 | void operator delete (void *p, size_t s); |
64 | }; |
61 | }; |
65 | |
62 | |
66 | // alas new/delete cannot be specified as inline in C++11 (see 17.6.4.6) |
|
|
67 | void *operator new (size_t s) throw (std::bad_alloc); |
|
|
68 | void operator delete (void *p) throw (); |
|
|
69 | |
|
|
70 | struct stringvec : simplevec<char *> |
63 | struct stringvec : simplevec<char *> |
71 | { |
64 | { |
72 | ~stringvec () |
65 | ~stringvec () |
73 | { |
66 | { |
74 | for (char **c = begin (); c != end (); c++) |
67 | for (char **c = begin (); c != end (); c++) |