CHROMA
typelist.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! @file
3  * @brief Typelist support
4  */
5 
6 #ifndef __typelist_h__
7 #define __typelist_h__
8 
9 #include "typemanip.h"
10 
11 namespace Chroma
12 {
13 
14 ////////////////////////////////////////////////////////////////////////////////
15 // class EmptyType
16 // Used as a class type that doesn't hold anything
17 // Useful as a strawman class
18 ////////////////////////////////////////////////////////////////////////////////
19 
20  class EmptyType {};
21 
22 ////////////////////////////////////////////////////////////////////////////////
23 // class NullType
24 // Used as a placeholder for "no type here"
25 // Useful as an end marker in typelists
26 ////////////////////////////////////////////////////////////////////////////////
27 
28  class NullType {};
29 
30 } // namespace Chroma
31 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 // macros TYPELIST_1, TYPELIST_2, ... TYPELIST_50
35 // Each takes a number of arguments equal to its numeric suffix
36 // The arguments are type names. TYPELIST_NN generates a typelist containing
37 // all types passed as arguments, in that order.
38 // Example: TYPELIST_2(char, int) generates a type containing char and int.
39 ////////////////////////////////////////////////////////////////////////////////
40 
41 #define TYPELIST_1(T1) ::Chroma::Typelist<T1, ::Chroma::NullType>
42 
43 #define TYPELIST_2(T1, T2) ::Chroma::Typelist<T1, TYPELIST_1(T2) >
44 
45 #define TYPELIST_3(T1, T2, T3) ::Chroma::Typelist<T1, TYPELIST_2(T2, T3) >
46 
47 #define TYPELIST_4(T1, T2, T3, T4) ::Chroma::Typelist<T1, TYPELIST_3(T2, T3, T4) >
48 
49 #define TYPELIST_5(T1, T2, T3, T4, T5) \
50  ::Chroma::Typelist<T1, TYPELIST_4(T2, T3, T4, T5) >
51 
52 #define TYPELIST_6(T1, T2, T3, T4, T5, T6) \
53  ::Chroma::Typelist<T1, TYPELIST_5(T2, T3, T4, T5, T6) >
54 
55 #define TYPELIST_7(T1, T2, T3, T4, T5, T6, T7) \
56  ::Chroma::Typelist<T1, TYPELIST_6(T2, T3, T4, T5, T6, T7) >
57 
58 #define TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8) \
59  ::Chroma::Typelist<T1, TYPELIST_7(T2, T3, T4, T5, T6, T7, T8) >
60 
61 #define TYPELIST_9(T1, T2, T3, T4, T5, T6, T7, T8, T9) \
62  ::Chroma::Typelist<T1, TYPELIST_8(T2, T3, T4, T5, T6, T7, T8, T9) >
63 
64 #define TYPELIST_10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \
65  ::Chroma::Typelist<T1, TYPELIST_9(T2, T3, T4, T5, T6, T7, T8, T9, T10) >
66 
67 #define TYPELIST_11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
68  ::Chroma::Typelist<T1, TYPELIST_10(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) >
69 
70 #define TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \
71  ::Chroma::Typelist<T1, TYPELIST_11(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
72  T11, T12) >
73 
74 #define TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \
75  ::Chroma::Typelist<T1, TYPELIST_12(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
76  T11, T12, T13) >
77 
78 #define TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
79  T11, T12, T13, T14) \
80  ::Chroma::Typelist<T1, TYPELIST_13(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
81  T11, T12, T13, T14) >
82 
83 #define TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
84  T11, T12, T13, T14, T15) \
85  ::Chroma::Typelist<T1, TYPELIST_14(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
86  T11, T12, T13, T14, T15) >
87 
88 #define TYPELIST_16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
89  T11, T12, T13, T14, T15, T16) \
90  ::Chroma::Typelist<T1, TYPELIST_15(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
91  T11, T12, T13, T14, T15, T16) >
92 
93 #define TYPELIST_17(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
94  T11, T12, T13, T14, T15, T16, T17) \
95  ::Chroma::Typelist<T1, TYPELIST_16(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
96  T11, T12, T13, T14, T15, T16, T17) >
97 
98 #define TYPELIST_18(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
99  T11, T12, T13, T14, T15, T16, T17, T18) \
100  ::Chroma::Typelist<T1, TYPELIST_17(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
101  T11, T12, T13, T14, T15, T16, T17, T18) >
102 
103 #define TYPELIST_19(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
104  T11, T12, T13, T14, T15, T16, T17, T18, T19) \
105  ::Chroma::Typelist<T1, TYPELIST_18(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
106  T11, T12, T13, T14, T15, T16, T17, T18, T19) >
107 
108 #define TYPELIST_20(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
109  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) \
110  ::Chroma::Typelist<T1, TYPELIST_19(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
111  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) >
112 
113 #define TYPELIST_21(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
114  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) \
115  ::Chroma::Typelist<T1, TYPELIST_20(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
116  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) >
117 
118 #define TYPELIST_22(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
119  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) \
120  ::Chroma::Typelist<T1, TYPELIST_21(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
121  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) >
122 
123 #define TYPELIST_23(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
124  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) \
125  ::Chroma::Typelist<T1, TYPELIST_22(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
126  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) >
127 
128 #define TYPELIST_24(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
129  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) \
130  ::Chroma::Typelist<T1, TYPELIST_23(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
131  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) >
132 
133 #define TYPELIST_25(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
134  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25) \
135  ::Chroma::Typelist<T1, TYPELIST_24(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
136  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
137  T21, T22, T23, T24, T25) >
138 
139 #define TYPELIST_26(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
140  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
141  T21, T22, T23, T24, T25, T26) \
142  ::Chroma::Typelist<T1, TYPELIST_25(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
143  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
144  T21, T22, T23, T24, T25, T26) >
145 
146 #define TYPELIST_27(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
147  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
148  T21, T22, T23, T24, T25, T26, T27) \
149  ::Chroma::Typelist<T1, TYPELIST_26(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
150  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
151  T21, T22, T23, T24, T25, T26, T27) >
152 
153 #define TYPELIST_28(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
154  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
155  T21, T22, T23, T24, T25, T26, T27, T28) \
156  ::Chroma::Typelist<T1, TYPELIST_27(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
157  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
158  T21, T22, T23, T24, T25, T26, T27, T28) >
159 
160 #define TYPELIST_29(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
161  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
162  T21, T22, T23, T24, T25, T26, T27, T28, T29) \
163  ::Chroma::Typelist<T1, TYPELIST_28(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
164  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
165  T21, T22, T23, T24, T25, T26, T27, T28, T29) >
166 
167 #define TYPELIST_30(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
168  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
169  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) \
170  ::Chroma::Typelist<T1, TYPELIST_29(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
171  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
172  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) >
173 
174 #define TYPELIST_31(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
175  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
176  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) \
177  ::Chroma::Typelist<T1, TYPELIST_30(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
178  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
179  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) >
180 
181 #define TYPELIST_32(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
182  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
183  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) \
184  ::Chroma::Typelist<T1, TYPELIST_31(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
185  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
186  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) >
187 
188 #define TYPELIST_33(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
189  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
190  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) \
191  ::Chroma::Typelist<T1, TYPELIST_32(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
192  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
193  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) >
194 
195 #define TYPELIST_34(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
196  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
197  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) \
198  ::Chroma::Typelist<T1, TYPELIST_33(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
199  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
200  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) >
201 
202 #define TYPELIST_35(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
203  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
204  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
205  T31, T32, T33, T34, T35) \
206  ::Chroma::Typelist<T1, TYPELIST_34(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
207  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
208  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
209  T31, T32, T33, T34, T35) >
210 
211 #define TYPELIST_36(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
212  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
213  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
214  T31, T32, T33, T34, T35, T36) \
215  ::Chroma::Typelist<T1, TYPELIST_35(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
216  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
217  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
218  T31, T32, T33, T34, T35, T36) >
219 
220 #define TYPELIST_37(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
221  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
222  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
223  T31, T32, T33, T34, T35, T36, T37) \
224  ::Chroma::Typelist<T1, TYPELIST_36(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
225  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
226  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
227  T31, T32, T33, T34, T35, T36, T37) >
228 
229 #define TYPELIST_38(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
230  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
231  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
232  T31, T32, T33, T34, T35, T36, T37, T38) \
233  ::Chroma::Typelist<T1, TYPELIST_37(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
234  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
235  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
236  T31, T32, T33, T34, T35, T36, T37, T38) >
237 
238 #define TYPELIST_39(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
239  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
240  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
241  T31, T32, T33, T34, T35, T36, T37, T38, T39) \
242  ::Chroma::Typelist<T1, TYPELIST_38(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
243  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
244  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
245  T31, T32, T33, T34, T35, T36, T37, T38, T39) >
246 
247 #define TYPELIST_40(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
248  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
249  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
250  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) \
251  ::Chroma::Typelist<T1, TYPELIST_39(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
252  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
253  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
254  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) >
255 
256 #define TYPELIST_41(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
257  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
258  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
259  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) \
260  ::Chroma::Typelist<T1, TYPELIST_40(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
261  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
262  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
263  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) >
264 
265 #define TYPELIST_42(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
266  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
267  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
268  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) \
269  ::Chroma::Typelist<T1, TYPELIST_41(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
270  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
271  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
272  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) >
273 
274 #define TYPELIST_43(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
275  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
276  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
277  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) \
278  ::Chroma::Typelist<T1, TYPELIST_42(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
279  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
280  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
281  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) >
282 
283 #define TYPELIST_44(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
284  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
285  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
286  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) \
287  ::Chroma::Typelist<T1, TYPELIST_43(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
288  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
289  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
290  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) >
291 
292 #define TYPELIST_45(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
293  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
294  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
295  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
296  T41, T42, T43, T44, T45) \
297  ::Chroma::Typelist<T1, TYPELIST_44(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
298  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
299  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
300  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
301  T41, T42, T43, T44, T45) >
302 
303 #define TYPELIST_46(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
304  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
305  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
306  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
307  T41, T42, T43, T44, T45, T46) \
308  ::Chroma::Typelist<T1, TYPELIST_45(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
309  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
310  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
311  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
312  T41, T42, T43, T44, T45) >
313 
314 #define TYPELIST_47(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
315  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
316  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
317  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
318  T41, T42, T43, T44, T45, T46, T47) \
319  ::Chroma::Typelist<T1, TYPELIST_46(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
320  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
321  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
322  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
323  T41, T42, T43, T44, T45, T46, T47) >
324 
325 #define TYPELIST_48(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
326  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
327  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
328  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
329  T41, T42, T43, T44, T45, T46, T47, T48) \
330  ::Chroma::Typelist<T1, TYPELIST_47(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
331  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
332  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
333  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
334  T41, T42, T43, T44, T45, T46, T47, T48) >
335 
336 #define TYPELIST_49(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
337  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
338  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
339  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
340  T41, T42, T43, T44, T45, T46, T47, T48, T49) \
341  ::Chroma::Typelist<T1, TYPELIST_48(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
342  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
343  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
344  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
345  T41, T42, T43, T44, T45, T46, T47, T48, T49) >
346 
347 #define TYPELIST_50(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
348  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
349  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
350  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
351  T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) \
352  ::Chroma::Typelist<T1, TYPELIST_49(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
353  T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
354  T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
355  T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
356  T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) >
357 
358 namespace Chroma
359 {
360 ////////////////////////////////////////////////////////////////////////////////
361 // class template Typelist
362 // The building block of typelists of any length
363 // Use it through the TYPELIST_NN macros
364 // Defines nested types:
365 // Head (first element, a non-typelist type by convention)
366 // Tail (second element, can be another typelist)
367 ////////////////////////////////////////////////////////////////////////////////
368 
369  template <class T, class U>
370  struct Typelist
371  {
372  typedef T Head;
373  typedef U Tail;
374  };
375 
376  namespace TL
377  {
378 ////////////////////////////////////////////////////////////////////////////////
379 // class template Length
380 // Computes the length of a typelist
381 // Invocation (TList is a typelist):
382 // Length<TList>::value
383 // returns a compile-time constant containing the length of TList, not counting
384 // the end terminator (which by convention is NullType)
385 ////////////////////////////////////////////////////////////////////////////////
386 
387  template <class TList> struct Length;
388  template <> struct Length<NullType>
389  {
390  enum { value = 0 };
391  };
392 
393  template <class T, class U>
394  struct Length< Typelist<T, U> >
395  {
396  enum { value = 1 + Length<U>::value };
397  };
398 
399 ////////////////////////////////////////////////////////////////////////////////
400 // class template TypeAt
401 // Finds the type at a given index in a typelist
402 // Invocation (TList is a typelist and index is a compile-time integral
403 // constant):
404 // TypeAt<TList, index>::Result
405 // returns the type in position 'index' in TList
406 // If you pass an out-of-bounds index, the result is a compile-time error
407 ////////////////////////////////////////////////////////////////////////////////
408 
409  template <class TList, int index> struct TypeAt;
410 
411  template <class Head, class Tail>
412  struct TypeAt<Typelist<Head, Tail>, 0>
413  {
414  typedef Head Result;
415  };
416 
417  template <class Head, class Tail, int i>
418  struct TypeAt<Typelist<Head, Tail>, i>
419  {
420  typedef typename TypeAt<Tail, i - 1>::Result Result;
421  };
422 
423 ////////////////////////////////////////////////////////////////////////////////
424 // class template TypeAtNonStrict
425 // Finds the type at a given index in a typelist
426 // Invocations (TList is a typelist and index is a compile-time integral
427 // constant):
428 // a) TypeAt<TList, index>::Result
429 // returns the type in position 'index' in TList, or NullType if index is
430 // out-of-bounds
431 // b) TypeAt<TList, index, D>::Result
432 // returns the type in position 'index' in TList, or D if index is out-of-bounds
433 ////////////////////////////////////////////////////////////////////////////////
434 
435  template <class TList, int index,
436  typename DefaultType = NullType>
438  {
439  typedef DefaultType Result;
440  };
441 
442  template <class Head, class Tail, typename DefaultType>
443  struct TypeAtNonStrict<Typelist<Head, Tail>, 0, DefaultType>
444  {
445  typedef Head Result;
446  };
447 
448  template <class Head, class Tail, int i, typename DefaultType>
449  struct TypeAtNonStrict<Typelist<Head, Tail>, i, DefaultType>
450  {
451  typedef typename
452  TypeAtNonStrict<Tail, i - 1, DefaultType>::Result Result;
453  };
454 
455 ////////////////////////////////////////////////////////////////////////////////
456 // class template IndexOf
457 // Finds the index of a type in a typelist
458 // Invocation (TList is a typelist and T is a type):
459 // IndexOf<TList, T>::value
460 // returns the position of T in TList, or NullType if T is not found in TList
461 ////////////////////////////////////////////////////////////////////////////////
462 
463  template <class TList, class T> struct IndexOf;
464 
465  template <class T>
466  struct IndexOf<NullType, T>
467  {
468  enum { value = -1 };
469  };
470 
471  template <class T, class Tail>
472  struct IndexOf<Typelist<T, Tail>, T>
473  {
474  enum { value = 0 };
475  };
476 
477  template <class Head, class Tail, class T>
478  struct IndexOf<Typelist<Head, Tail>, T>
479  {
480  private:
481  enum { temp = IndexOf<Tail, T>::value };
482  public:
483  enum { value = (temp == -1 ? -1 : 1 + temp) };
484  };
485 
486 ////////////////////////////////////////////////////////////////////////////////
487 // class template Append
488 // Appends a type or a typelist to another
489 // Invocation (TList is a typelist and T is either a type or a typelist):
490 // Append<TList, T>::Result
491 // returns a typelist that is TList followed by T and NullType-terminated
492 ////////////////////////////////////////////////////////////////////////////////
493 
494  template <class TList, class T> struct Append;
495 
496  template <> struct Append<NullType, NullType>
497  {
498  typedef NullType Result;
499  };
500 
501  template <class T> struct Append<NullType, T>
502  {
503  typedef TYPELIST_1(T) Result;
504  };
505 
506  template <class Head, class Tail>
507  struct Append<NullType, Typelist<Head, Tail> >
508  {
510  };
511 
512  template <class Head, class Tail, class T>
513  struct Append<Typelist<Head, Tail>, T>
514  {
515  typedef Typelist<Head,
516  typename Append<Tail, T>::Result>
518  };
519 
520 ////////////////////////////////////////////////////////////////////////////////
521 // class template Erase
522 // Erases the first occurence, if any, of a type in a typelist
523 // Invocation (TList is a typelist and T is a type):
524 // Erase<TList, T>::Result
525 // returns a typelist that is TList without the first occurence of T
526 ////////////////////////////////////////////////////////////////////////////////
527 
528  template <class TList, class T> struct Erase;
529 
530  template <class T> // Specialization 1
531  struct Erase<NullType, T>
532  {
533  typedef NullType Result;
534  };
535 
536  template <class T, class Tail> // Specialization 2
537  struct Erase<Typelist<T, Tail>, T>
538  {
539  typedef Tail Result;
540  };
541 
542  template <class Head, class Tail, class T> // Specialization 3
543  struct Erase<Typelist<Head, Tail>, T>
544  {
545  typedef Typelist<Head,
546  typename Erase<Tail, T>::Result>
548  };
549 
550 ////////////////////////////////////////////////////////////////////////////////
551 // class template EraseAll
552 // Erases all first occurences, if any, of a type in a typelist
553 // Invocation (TList is a typelist and T is a type):
554 // EraseAll<TList, T>::Result
555 // returns a typelist that is TList without any occurence of T
556 ////////////////////////////////////////////////////////////////////////////////
557 
558  template <class TList, class T> struct EraseAll;
559  template <class T>
560  struct EraseAll<NullType, T>
561  {
562  typedef NullType Result;
563  };
564  template <class T, class Tail>
565  struct EraseAll<Typelist<T, Tail>, T>
566  {
567  // Go all the way down the list removing the type
569  };
570  template <class Head, class Tail, class T>
571  struct EraseAll<Typelist<Head, Tail>, T>
572  {
573  // Go all the way down the list removing the type
574  typedef Typelist<Head,
575  typename EraseAll<Tail, T>::Result>
577  };
578 
579 ////////////////////////////////////////////////////////////////////////////////
580 // class template NoDuplicates
581 // Removes all duplicate types in a typelist
582 // Invocation (TList is a typelist):
583 // NoDuplicates<TList, T>::Result
584 ////////////////////////////////////////////////////////////////////////////////
585 
586  template <class TList> struct NoDuplicates;
587 
588  template <> struct NoDuplicates<NullType>
589  {
590  typedef NullType Result;
591  };
592 
593  template <class Head, class Tail>
594  struct NoDuplicates< Typelist<Head, Tail> >
595  {
596  private:
597  typedef typename NoDuplicates<Tail>::Result L1;
598  typedef typename Erase<L1, Head>::Result L2;
599  public:
601  };
602 
603 ////////////////////////////////////////////////////////////////////////////////
604 // class template Replace
605 // Replaces the first occurence of a type in a typelist, with another type
606 // Invocation (TList is a typelist, T, U are types):
607 // Replace<TList, T, U>::Result
608 // returns a typelist in which the first occurence of T is replaced with U
609 ////////////////////////////////////////////////////////////////////////////////
610 
611  template <class TList, class T, class U> struct Replace;
612 
613  template <class T, class U>
614  struct Replace<NullType, T, U>
615  {
616  typedef NullType Result;
617  };
618 
619  template <class T, class Tail, class U>
620  struct Replace<Typelist<T, Tail>, T, U>
621  {
623  };
624 
625  template <class Head, class Tail, class T, class U>
626  struct Replace<Typelist<Head, Tail>, T, U>
627  {
628  typedef Typelist<Head,
631  };
632 
633 ////////////////////////////////////////////////////////////////////////////////
634 // class template ReplaceAll
635 // Replaces all occurences of a type in a typelist, with another type
636 // Invocation (TList is a typelist, T, U are types):
637 // Replace<TList, T, U>::Result
638 // returns a typelist in which all occurences of T is replaced with U
639 ////////////////////////////////////////////////////////////////////////////////
640 
641  template <class TList, class T, class U> struct ReplaceAll;
642 
643  template <class T, class U>
644  struct ReplaceAll<NullType, T, U>
645  {
646  typedef NullType Result;
647  };
648 
649  template <class T, class Tail, class U>
650  struct ReplaceAll<Typelist<T, Tail>, T, U>
651  {
653  };
654 
655  template <class Head, class Tail, class T, class U>
656  struct ReplaceAll<Typelist<Head, Tail>, T, U>
657  {
658  typedef Typelist<Head,
661  };
662 
663 ////////////////////////////////////////////////////////////////////////////////
664 // class template Reverse
665 // Reverses a typelist
666 // Invocation (TList is a typelist):
667 // Reverse<TList>::Result
668 // returns a typelist that is TList reversed
669 ////////////////////////////////////////////////////////////////////////////////
670 
671  template <class TList> struct Reverse;
672 
673  template <class T>
674  struct Reverse< TYPELIST_1(T) >
675  {
676  typedef TYPELIST_1(T) Result;
677  };
678 
679  template <class Head, class Tail>
680  struct Reverse< Typelist<Head, Tail> >
681  {
682  typedef typename Append<
684  };
685 
686 ////////////////////////////////////////////////////////////////////////////////
687 // class template MostDerived
688 // Finds the type in a typelist that is the most derived from a given type
689 // Invocation (TList is a typelist, T is a type):
690 // Replace<TList, T>::Result
691 // returns the type in TList that's the most derived from T
692 ////////////////////////////////////////////////////////////////////////////////
693 
694  template <class TList, class T> struct MostDerived;
695 
696  template <class T>
698  {
699  typedef T Result;
700  };
701 
702  template <class Head, class Tail, class T>
703  struct MostDerived<Typelist<Head, Tail>, T>
704  {
705  private:
707  public:
708  typedef typename Select<
709  SUPERSUBCLASS(Candidate, Head),
711  };
712 
713 ////////////////////////////////////////////////////////////////////////////////
714 // class template DerivedToFront
715 // Arranges the types in a typelist so that the most derived types appear first
716 // Invocation (TList is a typelist):
717 // DerivedToFront<TList>::Result
718 // returns the reordered TList
719 ////////////////////////////////////////////////////////////////////////////////
720 
721  template <class TList> struct DerivedToFront;
722 
723  template <>
725  {
726  typedef NullType Result;
727  };
728 
729  template <class Head, class Tail>
730  struct DerivedToFront< Typelist<Head, Tail> >
731  {
732  private:
733  typedef typename MostDerived<Tail, Head>::Result
735  typedef typename Replace<Tail,
737  public:
739  };
740 
741  } // namespace TL
742 } // namespace Chroma
743 
744 #endif
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::T T
int i
Definition: pbg5p_w.cc:55
Typelist< Head, typename Append< Tail, T >::Result > Result
Definition: typelist.h:517
Replace< Tail, TheMostDerived, Head >::Result L
Definition: typelist.h:736
MostDerived< Tail, Head >::Result TheMostDerived
Definition: typelist.h:734
Typelist< Head, typename EraseAll< Tail, T >::Result > Result
Definition: typelist.h:576
EraseAll< Tail, T >::Result Result
Definition: typelist.h:568
Typelist< Head, typename Erase< Tail, T >::Result > Result
Definition: typelist.h:547
MostDerived< Tail, T >::Result Candidate
Definition: typelist.h:706
Select< SUPERSUBCLASS(Candidate, Head), Head, Candidate >::Result Result
Definition: typelist.h:710
Typelist< Head, typename ReplaceAll< Tail, T, U >::Result > Result
Definition: typelist.h:660
Typelist< U, typename ReplaceAll< Tail, T, U >::Result > Result
Definition: typelist.h:652
Typelist< Head, typename Replace< Tail, T, U >::Result > Result
Definition: typelist.h:630
Append< typename Reverse< Tail >::Result, Head >::Result Result
Definition: typelist.h:683
TypeAtNonStrict< Tail, i - 1, DefaultType >::Result Result
Definition: typelist.h:452
TypeAt< Tail, i - 1 >::Result Result
Definition: typelist.h:420
#define index(c)
multi1d< LatticeColorMatrix > U
#define TYPELIST_1(T1)
Definition: typelist.h:41
Type manipulator support.
#define SUPERSUBCLASS(T, U)
Definition: typemanip.h:140