4 (c) 1996--2003 Han-Wen Nienhuys
9 #define ONE_OPERATOR(type, function, op) \
11 operator op (type t1, type t2) {\
12 return function (t1, t2) op 0;\
15 #define GPP_MINMAX_OPERATOR(type, op, opp) \
17 operator op (type t1, type t2)\
19 return (t1 opp t2) ? t1 : t2;\
23 #if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
24 #define GPP_MINMAX(type, prefix)\
25 prefix GPP_MINMAX_OPERATOR (type, <?, <)\
26 prefix GPP_MINMAX_OPERATOR (type, >?, >)
28 #define GPP_MINMAX(type, prefix)
31 /** handy notations for a signed comparison.
32 make the operators{<,<=,==,>=,>} and the MAX and MIN of two.
33 Please fill a & in the type argument if necessary.
35 #define TEMPLATE_INSTANTIATE_COMPARE(type, function, prefix) \
36 prefix ONE_OPERATOR (type, function, >)\
37 prefix ONE_OPERATOR (type, function, >=)\
38 prefix ONE_OPERATOR (type, function, ==)\
39 prefix ONE_OPERATOR (type, function, !=)\
40 prefix ONE_OPERATOR (type, function, <)\
41 prefix ONE_OPERATOR (type, function, <=)\
42 GPP_MINMAX (type, prefix)\
43 prefix inline type max (type t1, type t2) { return (t1 > t2)? t1 : t2; }\
44 prefix inline type min (type t1, type t2) { return (t1 < t2)? t1 : t2; }\
46 prefix bool operator< (type t1, type t2) /* stupid fix to allow ; */
50 #define INSTANTIATE_COMPARE(type, func) TEMPLATE_INSTANTIATE_COMPARE (type,func,)