Manicore
Library to implement schemes on n-dimensionnal manifolds.
src
Common
preprocessor.hpp
Go to the documentation of this file.
1
#ifndef PREPROCESSOR_HPP_INCLUDED
2
#define PREPROCESSOR_HPP_INCLUDED
3
10
#define EMPTY()
11
#define DEFER(id) id EMPTY()
12
#define OBSTRUCT(id) id DEFER(EMPTY)()
13
#define EXPAND(...) __VA_ARGS__
14
15
#define EVAL(...) EVAL1(EVAL1(EVAL1(__VA_ARGS__)))
16
#define EVAL1(...) EVAL2(EVAL2(EVAL2(__VA_ARGS__)))
17
#define EVAL2(...) EVAL3(EVAL3(EVAL3(__VA_ARGS__)))
18
#define EVAL3(...) EVAL4(EVAL4(EVAL4(__VA_ARGS__)))
19
#define EVAL4(...) EVAL5(EVAL5(EVAL5(__VA_ARGS__)))
20
#define EVAL5(...) __VA_ARGS__
21
22
#define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
23
#define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
24
25
#define CHECK_N(x, n, ...) n
26
#define CHECK(...) CHECK_N(__VA_ARGS__, 0,)
27
28
#define NOT(x) CHECK(PRIMITIVE_CAT(NOT_, x))
29
#define NOT_0 ~, 1,
30
31
#define COMPL(b) PRIMITIVE_CAT(COMPL_, b)
32
#define COMPL_0 1
33
#define COMPL_1 0
34
35
#define BOOL(x) COMPL(NOT(x))
36
37
#define IIF(c) PRIMITIVE_CAT(IIF_, c)
38
#define IIF_0(t, ...) __VA_ARGS__
39
#define IIF_1(t, ...) t
40
41
#define IF(c) IIF(BOOL(c))
42
43
#define WHILE(pred, op, cont, ...) \
44
IF(pred(__VA_ARGS__)) \
45
( \
46
op(__VA_ARGS__) \
47
OBSTRUCT(WHILE_INDIRECT) () \
48
( \
49
pred, op, cont, cont(__VA_ARGS__) \
50
) \
51
)
52
#define WHILE_INDIRECT() WHILE
53
54
#define IS_0(x) CHECK(PRIMITIVE_CAT(IS_0_, x))
55
#define IS_0_0 ~, 1,
56
57
#define IS_1(x) CHECK(PRIMITIVE_CAT(IS_1_, x))
58
#define IS_1_1 ~, 1,
59
60
#define IIF_ELSE_2(c) PRIMITIVE_CAT(IIF_ELSE_2_, c)
61
#define IIF_ELSE_2_0(t1, t2, f1, f2, ...) f1, f2
62
#define IIF_ELSE_2_1(t1, t2, f1, f2, ...) t1, t2
63
64
#define IF_ELSE_2(c) IIF_ELSE_2(BOOL(c))
65
66
# define DEC(x) PRIMITIVE_CAT(DEC_, x)
67
# define DEC_0 0
68
# define DEC_1 0
69
# define DEC_2 1
70
# define DEC_3 2
71
# define DEC_4 3
72
# define DEC_5 4
73
# define DEC_6 5
74
# define DEC_7 6
75
# define DEC_8 7
76
# define DEC_9 8
77
# define DEC_10 9
78
# define DEC_11 10
79
# define DEC_12 11
80
# define DEC_13 12
81
# define DEC_14 13
82
# define DEC_15 14
83
# define DEC_16 15
84
# define DEC_17 16
85
# define DEC_18 17
86
# define DEC_19 18
87
# define DEC_20 19
88
# define DEC_21 20
89
# define DEC_22 21
90
# define DEC_23 22
91
# define DEC_24 23
92
# define DEC_25 24
93
# define DEC_26 25
94
# define DEC_27 26
95
# define DEC_28 27
96
# define DEC_29 28
97
# define DEC_30 29
98
# define DEC_31 30
99
# define DEC_32 31
100
# define DEC_33 32
101
# define DEC_34 33
102
# define DEC_35 34
103
# define DEC_36 35
104
# define DEC_37 36
105
# define DEC_38 37
106
# define DEC_39 38
107
# define DEC_40 39
108
# define DEC_41 40
109
# define DEC_42 41
110
# define DEC_43 42
111
# define DEC_44 43
112
# define DEC_45 44
113
# define DEC_46 45
114
# define DEC_47 46
115
# define DEC_48 47
116
# define DEC_49 48
117
# define DEC_50 49
118
# define DEC_51 50
119
# define DEC_52 51
120
# define DEC_53 52
121
# define DEC_54 53
122
# define DEC_55 54
123
# define DEC_56 55
124
# define DEC_57 56
125
# define DEC_58 57
126
# define DEC_59 58
127
# define DEC_60 59
128
# define DEC_61 60
129
# define DEC_62 61
130
# define DEC_63 62
131
# define DEC_64 63
132
# define DEC_65 64
133
# define DEC_66 65
134
# define DEC_67 66
135
# define DEC_68 67
136
# define DEC_69 68
137
# define DEC_70 69
138
# define DEC_71 70
139
# define DEC_72 71
140
# define DEC_73 72
141
# define DEC_74 73
142
# define DEC_75 74
143
# define DEC_76 75
144
# define DEC_77 76
145
# define DEC_78 77
146
# define DEC_79 78
147
# define DEC_80 79
148
# define DEC_81 80
149
# define DEC_82 81
150
# define DEC_83 82
151
# define DEC_84 83
152
# define DEC_85 84
153
# define DEC_86 85
154
# define DEC_87 86
155
# define DEC_88 87
156
# define DEC_89 88
157
# define DEC_90 89
158
# define DEC_91 90
159
# define DEC_92 91
160
# define DEC_93 92
161
# define DEC_94 93
162
# define DEC_95 94
163
# define DEC_96 95
164
# define DEC_97 96
165
# define DEC_98 97
166
# define DEC_99 98
167
# define DEC_100 99
168
# define DEC_101 100
169
# define DEC_102 101
170
# define DEC_103 102
171
# define DEC_104 103
172
# define DEC_105 104
173
# define DEC_106 105
174
# define DEC_107 106
175
# define DEC_108 107
176
# define DEC_109 108
177
# define DEC_110 109
178
# define DEC_111 110
179
# define DEC_112 111
180
# define DEC_113 112
181
# define DEC_114 113
182
# define DEC_115 114
183
# define DEC_116 115
184
# define DEC_117 116
185
# define DEC_118 117
186
# define DEC_119 118
187
# define DEC_120 119
188
# define DEC_121 120
189
# define DEC_122 121
190
# define DEC_123 122
191
# define DEC_124 123
192
# define DEC_125 124
193
# define DEC_126 125
194
# define DEC_127 126
195
# define DEC_128 127
196
# define DEC_129 128
197
# define DEC_130 129
198
# define DEC_131 130
199
# define DEC_132 131
200
# define DEC_133 132
201
# define DEC_134 133
202
# define DEC_135 134
203
# define DEC_136 135
204
# define DEC_137 136
205
# define DEC_138 137
206
# define DEC_139 138
207
# define DEC_140 139
208
# define DEC_141 140
209
# define DEC_142 141
210
# define DEC_143 142
211
# define DEC_144 143
212
# define DEC_145 144
213
# define DEC_146 145
214
# define DEC_147 146
215
# define DEC_148 147
216
# define DEC_149 148
217
# define DEC_150 149
218
# define DEC_151 150
219
# define DEC_152 151
220
# define DEC_153 152
221
# define DEC_154 153
222
# define DEC_155 154
223
# define DEC_156 155
224
# define DEC_157 156
225
# define DEC_158 157
226
# define DEC_159 158
227
# define DEC_160 159
228
# define DEC_161 160
229
# define DEC_162 161
230
# define DEC_163 162
231
# define DEC_164 163
232
# define DEC_165 164
233
# define DEC_166 165
234
# define DEC_167 166
235
# define DEC_168 167
236
# define DEC_169 168
237
# define DEC_170 169
238
# define DEC_171 170
239
# define DEC_172 171
240
# define DEC_173 172
241
# define DEC_174 173
242
# define DEC_175 174
243
# define DEC_176 175
244
# define DEC_177 176
245
# define DEC_178 177
246
# define DEC_179 178
247
# define DEC_180 179
248
# define DEC_181 180
249
# define DEC_182 181
250
# define DEC_183 182
251
# define DEC_184 183
252
# define DEC_185 184
253
# define DEC_186 185
254
# define DEC_187 186
255
# define DEC_188 187
256
# define DEC_189 188
257
# define DEC_190 189
258
# define DEC_191 190
259
# define DEC_192 191
260
# define DEC_193 192
261
# define DEC_194 193
262
# define DEC_195 194
263
# define DEC_196 195
264
# define DEC_197 196
265
# define DEC_198 197
266
# define DEC_199 198
267
# define DEC_200 199
268
# define DEC_201 200
269
# define DEC_202 201
270
# define DEC_203 202
271
# define DEC_204 203
272
# define DEC_205 204
273
# define DEC_206 205
274
# define DEC_207 206
275
# define DEC_208 207
276
# define DEC_209 208
277
# define DEC_210 209
278
# define DEC_211 210
279
# define DEC_212 211
280
# define DEC_213 212
281
# define DEC_214 213
282
# define DEC_215 214
283
# define DEC_216 215
284
# define DEC_217 216
285
# define DEC_218 217
286
# define DEC_219 218
287
# define DEC_220 219
288
# define DEC_221 220
289
# define DEC_222 221
290
# define DEC_223 222
291
# define DEC_224 223
292
# define DEC_225 224
293
# define DEC_226 225
294
# define DEC_227 226
295
# define DEC_228 227
296
# define DEC_229 228
297
# define DEC_230 229
298
# define DEC_231 230
299
# define DEC_232 231
300
# define DEC_233 232
301
# define DEC_234 233
302
# define DEC_235 234
303
# define DEC_236 235
304
# define DEC_237 236
305
# define DEC_238 237
306
# define DEC_239 238
307
# define DEC_240 239
308
# define DEC_241 240
309
# define DEC_242 241
310
# define DEC_243 242
311
# define DEC_244 243
312
# define DEC_245 244
313
# define DEC_246 245
314
# define DEC_247 246
315
# define DEC_248 247
316
# define DEC_249 248
317
# define DEC_250 249
318
# define DEC_251 250
319
# define DEC_252 251
320
# define DEC_253 252
321
# define DEC_254 253
322
# define DEC_255 254
323
# define DEC_256 255
324
# define DEC_257 256
325
326
#endif
327
Generated by
1.9.1