]> git.donarmstrong.com Git - lilypond.git/blob - flower/compare.hh
release: 0.0.13
[lilypond.git] / flower / compare.hh
1 /*
2   flowerlib
3
4   (c) 1996 Han-Wen Nienhuys
5   */
6 #ifndef COMPARE_HH
7 #define COMPARE_HH
8
9 #define one_operator(type, function, op) \
10 inline bool \
11 operator op (type t1, type t2) {\
12     return function(t1, t2) op 0;\
13 }\
14
15 #define gpp_minmax_operator(type, op, opp) \
16 inline type \
17 operator op(type t1, type t2)\
18 {\
19      return (t1 opp t2) ? t1 :  t2;\
20 }\
21
22 #ifdef __GNUC__
23 #define gpp_minmax(type, prefix)\
24        prefix gpp_minmax_operator(type, <?, <)\
25        prefix gpp_minmax_operator(type, >?, >)
26 #else
27 #define gpp_minmax(type, prefix)
28 #endif
29
30 /// handy notations for a signed comparison
31 #define template_instantiate_compare(type, function, prefix) \
32 prefix one_operator(type, function, >)\
33 prefix one_operator(type, function, >=)\
34 prefix one_operator(type, function, ==)\
35 prefix one_operator(type, function, !=)\
36 prefix one_operator(type, function, <)\
37 prefix one_operator(type, function, <=)\
38 gpp_minmax(type, prefix)\
39 prefix inline type MAX(type t1, type t2) {  return (t1 > t2 )? t1 : t2; }\
40 prefix inline type MIN(type t1, type t2) {  return (t1 < t2 )? t1 : t2; }\
41   \
42 prefix  bool operator<(type t1, type t2) /* stupid fix to allow ; */
43      /**
44     make the operators{<,<=,==,>=,>} and the MAX and MIN of two.
45     Please fill a & in the type argument if necessary.    
46     */
47
48
49     
50 #define instantiate_compare(type, func) template_instantiate_compare(type,func, )
51      
52
53      
54 #endif
55