]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/compare.hh
Run grand-replace (issue 3765)
[lilypond.git] / flower / include / compare.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1996--2014 Han-Wen Nienhuys
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef COMPARE_HH
20 #define COMPARE_HH
21
22 #define ONE_OPERATOR(type, function, op)        \
23   inline bool                                   \
24   operator op (type t1, type t2)                \
25   {                                             \
26     return function (t1, t2) op 0;              \
27   }
28
29 /**  handy notations for a signed comparison.
30      make the operators{<,<=,==,>=,>} and the MAX and MIN of two.
31      Please fill a & in the type argument if necessary.
32 */
33 #define TEMPLATE_INSTANTIATE_COMPARE(type, function, prefix)            \
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     prefix ONE_OPERATOR (type, function, <)                             \
39     prefix ONE_OPERATOR (type, function, <=)                            \
40     /* namespace std { */                                               \
41     prefix inline type max (type t1, type t2) { return (t1 > t2) ? t1 : t2; } \
42     prefix inline type min (type t1, type t2) { return (t1 < t2) ? t1 : t2; } \
43   /* } */                                                               \
44   /* stupid fix to allow ; */                                           \
45   prefix bool operator < (type t1, type t2)
46
47 #define INSTANTIATE_COMPARE(type, func) TEMPLATE_INSTANTIATE_COMPARE (type, func,)
48
49 #endif
50