WARPXM v1.10.0
Loading...
Searching...
No Matches
wxtypelist.h
Go to the documentation of this file.
1#ifndef wxtypelist_h
2#define wxtypelist_h
3
4// WarpX includes
5
6// std includes
7
12class WxNullType; // does nothing, just serves as a sentinel
13
21template<class T, class U> struct WxTypeList
22{
23 typedef T Head;
24 typedef U Tail;
25};
26
27// The following macros were generated automatically. They make
28// constructing new typelists quite easy. For example, a four element
29// typelist can be created using
30//
31// WX_TYPELIST_4(int, usigned int, char, unsigned char)
32//
33#define WX_TYPELIST_1(t1) WxTypeList<t1, WxNullType>
34#define WX_TYPELIST_2(t1, t2) WxTypeList<t1, WX_TYPELIST_1(t2)>
35#define WX_TYPELIST_3(t1, t2, t3) WxTypeList<t1, WX_TYPELIST_2(t2, t3)>
36#define WX_TYPELIST_4(t1, t2, t3, t4) WxTypeList<t1, WX_TYPELIST_3(t2, t3, t4)>
37#define WX_TYPELIST_5(t1, t2, t3, t4, t5) WxTypeList<t1, WX_TYPELIST_4(t2, t3, t4, t5)>
38#define WX_TYPELIST_6(t1, t2, t3, t4, t5, t6) \
39 WxTypeList<t1, WX_TYPELIST_5(t2, t3, t4, t5, t6)>
40#define WX_TYPELIST_7(t1, t2, t3, t4, t5, t6, t7) \
41 WxTypeList<t1, WX_TYPELIST_6(t2, t3, t4, t5, t6, t7)>
42#define WX_TYPELIST_8(t1, t2, t3, t4, t5, t6, t7, t8) \
43 WxTypeList<t1, WX_TYPELIST_7(t2, t3, t4, t5, t6, t7, t8)>
44#define WX_TYPELIST_9(t1, t2, t3, t4, t5, t6, t7, t8, t9) \
45 WxTypeList<t1, WX_TYPELIST_8(t2, t3, t4, t5, t6, t7, t8, t9)>
46#define WX_TYPELIST_10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) \
47 WxTypeList<t1, WX_TYPELIST_9(t2, t3, t4, t5, t6, t7, t8, t9, t10)>
48#define WX_TYPELIST_11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) \
49 WxTypeList<t1, WX_TYPELIST_10(t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)>
50#define WX_TYPELIST_12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) \
51 WxTypeList<t1, WX_TYPELIST_11(t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12)>
52#define WX_TYPELIST_13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) \
53 WxTypeList<t1, WX_TYPELIST_12(t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13)>
54#define WX_TYPELIST_14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) \
55 WxTypeList<t1, \
56 WX_TYPELIST_13(t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14)>
57#define WX_TYPELIST_15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) \
58 WxTypeList<t1, \
59 WX_TYPELIST_14( \
60 t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15)>
61#define WX_TYPELIST_16( \
62 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) \
63 WxTypeList<t1, \
64 WX_TYPELIST_15( \
65 t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16)>
66#define WX_TYPELIST_17( \
67 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) \
68 WxTypeList< \
69 t1, \
70 WX_TYPELIST_16( \
71 t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17)>
72#define WX_TYPELIST_18( \
73 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) \
74 WxTypeList<t1, \
75 WX_TYPELIST_17(t2, \
76 t3, \
77 t4, \
78 t5, \
79 t6, \
80 t7, \
81 t8, \
82 t9, \
83 t10, \
84 t11, \
85 t12, \
86 t13, \
87 t14, \
88 t15, \
89 t16, \
90 t17, \
91 t18)>
92#define WX_TYPELIST_19(t1, \
93 t2, \
94 t3, \
95 t4, \
96 t5, \
97 t6, \
98 t7, \
99 t8, \
100 t9, \
101 t10, \
102 t11, \
103 t12, \
104 t13, \
105 t14, \
106 t15, \
107 t16, \
108 t17, \
109 t18, \
110 t19) \
111 WxTypeList<t1, \
112 WX_TYPELIST_18(t2, \
113 t3, \
114 t4, \
115 t5, \
116 t6, \
117 t7, \
118 t8, \
119 t9, \
120 t10, \
121 t11, \
122 t12, \
123 t13, \
124 t14, \
125 t15, \
126 t16, \
127 t17, \
128 t18, \
129 t19)>
130#define WX_TYPELIST_20(t1, \
131 t2, \
132 t3, \
133 t4, \
134 t5, \
135 t6, \
136 t7, \
137 t8, \
138 t9, \
139 t10, \
140 t11, \
141 t12, \
142 t13, \
143 t14, \
144 t15, \
145 t16, \
146 t17, \
147 t18, \
148 t19, \
149 t20) \
150 WxTypeList<t1, \
151 WX_TYPELIST_19(t2, \
152 t3, \
153 t4, \
154 t5, \
155 t6, \
156 t7, \
157 t8, \
158 t9, \
159 t10, \
160 t11, \
161 t12, \
162 t13, \
163 t14, \
164 t15, \
165 t16, \
166 t17, \
167 t18, \
168 t19, \
169 t20)>
170
178template<class TList, template<class> class Unit> class WxTypeMap;
179
184template<class T1, class T2, template<class> class Unit>
185class WxTypeMap<WxTypeList<T1, T2>, Unit> : public WxTypeMap<T1, Unit>,
186 public WxTypeMap<T2, Unit>
187{
188public:
189 template<typename T> struct Rebind
190 {
191 typedef Unit<T> Result;
192 };
193};
194
198template<class AtomicType, template<class> class Unit>
199class WxTypeMap : public Unit<AtomicType>
200{
201public:
202 template<typename T> struct Rebind
203 {
204 typedef Unit<T> Result;
205 };
206};
207
211template<template<class> class Unit> class WxTypeMap<WxNullType, Unit>
212{
213public:
214 template<typename T> struct Rebind
215 {
216 typedef Unit<T> Result;
217 };
218};
219
225template<class T, class H>
226typename H::template Rebind<T>::Result& wxTypeMapExtract(H& obj)
227{
228 return obj;
229}
230
231template<class T, class H>
232const typename H::template Rebind<T>::Result& wxTypeMapExtract(const H& obj)
233{
234 return obj;
235}
236
238#endif // wxtypelist_h
WxTypeMap can be used to generate a whole class hierachy at compile time.
Definition: wxtypelist.h:200
H::template Rebind< T >::Result & wxTypeMapExtract(H &obj)
Say one has created WxTypeMap from a typelist and class Unit.
Definition: wxtypelist.h:226
WxTypeList class provides a means of defining a list of types (hence the name "typelist").
Definition: wxtypelist.h:22
U Tail
Definition: wxtypelist.h:24
T Head
Definition: wxtypelist.h:23
Definition: wxtypelist.h:203
Unit< T > Result
Definition: wxtypelist.h:204
Unit< T > Result
Definition: wxtypelist.h:216
Unit< T > Result
Definition: wxtypelist.h:191