5 * macros to define comparison operators for classes with small numbers of members.
8 #define WRITE_EQ_OPERATORS_1(type, a) \
9 inline bool operator==(const type &l, const type &r) { \
12 inline bool operator!=(const type &l, const type &r) { \
16 #define WRITE_CMP_OPERATORS_1(type, a) \
17 inline bool operator>(const type &l, const type &r) { \
20 inline bool operator<(const type &l, const type &r) { \
23 inline bool operator>=(const type &l, const type &r) { \
26 inline bool operator<=(const type &l, const type &r) { \
30 #define WRITE_EQ_OPERATORS_2(type, a, b) \
31 inline bool operator==(const type &l, const type &r) { \
32 return l.a == r.a && l.b == r.b; \
34 inline bool operator!=(const type &l, const type &r) { \
35 return l.a != r.a || l.b != r.b; \
38 #define WRITE_CMP_OPERATORS_2(type, a, b) \
39 inline bool operator>(const type &l, const type &r) { \
41 (l.a == r.a && (l.b > r.b)); \
43 inline bool operator<(const type &l, const type &r) { \
45 (l.a == r.a && (l.b < r.b)); \
47 inline bool operator>=(const type &l, const type &r) { \
49 (l.a == r.a && (l.b >= r.b)); \
51 inline bool operator<=(const type &l, const type &r) { \
53 (l.a == r.a && (l.b <= r.b)); \
57 #define WRITE_EQ_OPERATORS_3(type, a, b, c) \
58 inline bool operator==(const type &l, const type &r) { \
59 return l.a == r.a && l.b == r.b && l.c == r.c; \
61 inline bool operator!=(const type &l, const type &r) { \
62 return l.a != r.a || l.b != r.b || l.c != r.c; \
65 #define WRITE_CMP_OPERATORS_3(type, a, b, c) \
66 inline bool operator>(const type &l, const type &r) { \
68 (l.a == r.a && (l.b > r.b || \
69 (l.b == r.b && (l.c > r.c)))); \
71 inline bool operator<(const type &l, const type &r) { \
73 (l.a == r.a && (l.b < r.b || \
74 (l.b == r.b && (l.c < r.c)))); \
76 inline bool operator>=(const type &l, const type &r) { \
78 (l.a == r.a && (l.b > r.b || \
79 (l.b == r.b && (l.c >= r.c)))); \
81 inline bool operator<=(const type &l, const type &r) { \
83 (l.a == r.a && (l.b < r.b || \
84 (l.b == r.b && (l.c <= r.c)))); \
87 #define WRITE_EQ_OPERATORS_4(type, a, b, c, d) \
88 inline bool operator==(const type &l, const type &r) { \
89 return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d; \
91 inline bool operator!=(const type &l, const type &r) { \
92 return l.a != r.a || l.b != r.b || l.c != r.c || l.d != r.d; \
95 #define WRITE_CMP_OPERATORS_4(type, a, b, c, d) \
96 inline bool operator>(const type &l, const type &r) { \
98 (l.a == r.a && (l.b > r.b || \
99 (l.b == r.b && (l.c > r.c || \
100 (l.c == r.c && (l.d > r.d)))))); \
102 inline bool operator<(const type &l, const type &r) { \
103 return l.a < r.a || \
104 (l.a == r.a && (l.b < r.b || \
105 (l.b == r.b && (l.c < r.c || \
106 (l.c == r.c && (l.d < r.d)))))); \
108 inline bool operator>=(const type &l, const type &r) { \
109 return l.a > r.a || \
110 (l.a == r.a && (l.b > r.b || \
111 (l.b == r.b && (l.c > r.c || \
112 (l.c == r.c && (l.d >= r.d)))))); \
114 inline bool operator<=(const type &l, const type &r) { \
115 return l.a < r.a || \
116 (l.a == r.a && (l.b < r.b || \
117 (l.b == r.b && (l.c < r.c || \
118 (l.c == r.c && (l.d <= r.d)))))); \
123 #define WRITE_EQ_OPERATORS_5(type, a, b, c, d, e) \
124 inline bool operator==(const type &l, const type &r) { \
125 return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d && l.e == r.e; \
127 inline bool operator!=(const type &l, const type &r) { \
128 return l.a != r.a || l.b != r.b || l.c != r.c || l.d != r.d || l.e != r.e; \
131 #define WRITE_CMP_OPERATORS_5(type, a, b, c, d, e) \
132 inline bool operator>(const type &l, const type &r) { \
133 return l.a > r.a || \
134 (l.a == r.a && (l.b > r.b || \
135 (l.b == r.b && (l.c > r.c || \
136 (l.c == r.c && (l.d > r.d || \
137 (l.d == r.d && l.e > r.e))))))); \
139 inline bool operator<(const type &l, const type &r) { \
140 return l.a < r.a || \
141 (l.a == r.a && (l.b < r.b || \
142 (l.b == r.b && (l.c < r.c || \
143 (l.c == r.c && (l.d < r.d || \
144 (l.d == r.d && (l.e < r.e)))))))); \
146 inline bool operator>=(const type &l, const type &r) { \
147 return l.a > r.a || \
148 (l.a == r.a && (l.b > r.b || \
149 (l.b == r.b && (l.c > r.c || \
150 (l.c == r.c && (l.d > r.d || \
151 (l.d == r.d && l.e >= r.e))))))); \
153 inline bool operator<=(const type &l, const type &r) { \
154 return l.a < r.a || \
155 (l.a == r.a && (l.b < r.b || \
156 (l.b == r.b && (l.c < r.c || \
157 (l.c == r.c && (l.d < r.d || \
158 (l.d == r.d && l.e <= r.e))))))); \
161 #define WRITE_EQ_OPERATORS_7(type, a, b, c, d, e, f, g) \
162 inline bool operator==(const type &l, const type &r) { \
163 return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d && l.e == r.e && l.f == r.f && l.g == r.g; \
165 inline bool operator!=(const type &l, const type &r) { \
166 return l.a != r.a || l.b != r.b || l.c != r.c || l.d != r.d || l.e != r.e || l.f != r.f || l.g != r.g; \
168 #define WRITE_CMP_OPERATORS_7(type, a, b, c, d, e, f, g) \
169 inline bool operator<=(const type &l, const type &r) { \
170 return l.a < r.a || \
171 (l.a == r.a && (l.b < r.b || \
172 (l.b == r.b && (l.c < r.c || \
173 (l.c == r.c && (l.d < r.d || \
174 (l.d == r.d && (l.e < r.e || \
175 (l.e == r.e && (l.f < r.f || \
176 (l.f == r.f && l.g <= r.g))))))))))); \
178 inline bool operator>=(const type &l, const type &r) { \
179 return l.a > r.a || \
180 (l.a == r.a && (l.b > r.b || \
181 (l.b == r.b && (l.c > r.c || \
182 (l.c == r.c && (l.d > r.d || \
183 (l.d == r.d && (l.e > r.e || \
184 (l.e == r.e && (l.f > r.f || \
185 (l.f == r.f && l.g >= r.g))))))))))); \
187 inline bool operator>(const type &l, const type &r) { \
188 return l.a > r.a || \
189 (l.a == r.a && (l.b > r.b || \
190 (l.b == r.b && (l.c > r.c || \
191 (l.c == r.c && (l.d > r.d || \
192 (l.d == r.d && (l.e > r.e || \
193 (l.e == r.e && (l.f > r.f || \
194 (l.f == r.f && l.g > r.g))))))))))); \
196 inline bool operator<(const type &l, const type &r) { \
197 return l.a < r.a || \
198 (l.a == r.a && (l.b < r.b || \
199 (l.b == r.b && (l.c < r.c || \
200 (l.c == r.c && (l.d < r.d || \
201 (l.d == r.d && (l.e < r.e || \
202 (l.e == r.e && (l.f < r.f || \
203 (l.f == r.f && l.g < r.g))))))))))); \