]>
Commit | Line | Data |
---|---|---|
fd1e1726 BK |
1 | // -*- C++ -*- |
2 | ||
a5544970 | 3 | // Copyright (C) 2005-2019 Free Software Foundation, Inc. |
fd1e1726 BK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
fd1e1726 BK |
9 | // any later version. |
10 | ||
11 | // This library 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 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
fd1e1726 BK |
24 | |
25 | // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. | |
26 | ||
27 | // Permission to use, copy, modify, sell, and distribute this software | |
28 | // is hereby granted without fee, provided that the above copyright | |
29 | // notice appears in all copies, and that both that copyright notice and | |
30 | // this permission notice appear in supporting documentation. None of | |
31 | // the above authors, nor IBM Haifa Research Laboratories, make any | |
32 | // representation about the suitability of this software for any | |
33 | // purpose. It is provided "as is" without express or implied warranty. | |
34 | ||
35 | /** | |
f910786b BK |
36 | * @file ext/typelist.h |
37 | * This file is a GNU extension to the Standard C++ Library. | |
38 | * | |
39 | * Contains typelist_chain definitions. | |
40 | * Typelists are an idea by Andrei Alexandrescu. | |
fd1e1726 BK |
41 | */ |
42 | ||
d7f245b1 BK |
43 | #ifndef _TYPELIST_H |
44 | #define _TYPELIST_H 1 | |
cbe5ba46 BK |
45 | |
46 | #include <ext/type_traits.h> | |
fd1e1726 | 47 | |
12ffa228 BK |
48 | namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) |
49 | { | |
50 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
3cbc7af0 | 51 | |
939759fc BK |
52 | /** @namespace __gnu_cxx::typelist |
53 | * @brief GNU typelist extensions for public compile-time use. | |
54 | */ | |
cad367a6 BK |
55 | namespace typelist |
56 | { | |
fd1e1726 BK |
57 | struct null_type { }; |
58 | ||
59 | template<typename Root> | |
cad367a6 | 60 | struct node |
fd1e1726 BK |
61 | { |
62 | typedef Root root; | |
63 | }; | |
64 | ||
65 | // Forward declarations of functors. | |
66 | template<typename Hd, typename Typelist> | |
67 | struct chain | |
68 | { | |
69 | typedef Hd head; | |
70 | typedef Typelist tail; | |
71 | }; | |
72 | ||
d466a7e2 BK |
73 | // Apply all typelist types to unary functor. |
74 | template<typename Fn, typename Typelist> | |
d7f245b1 BK |
75 | void |
76 | apply(Fn&, Typelist); | |
77 | ||
d466a7e2 BK |
78 | /// Apply all typelist types to generator functor. |
79 | template<typename Gn, typename Typelist> | |
80 | void | |
81 | apply_generator(Gn&, Typelist); | |
82 | ||
83 | // Apply all typelist types and values to generator functor. | |
84 | template<typename Gn, typename TypelistT, typename TypelistV> | |
85 | void | |
86 | apply_generator(Gn&, TypelistT, TypelistV); | |
87 | ||
fd1e1726 BK |
88 | template<typename Typelist0, typename Typelist1> |
89 | struct append; | |
90 | ||
91 | template<typename Typelist_Typelist> | |
cad367a6 | 92 | struct append_typelist; |
fd1e1726 BK |
93 | |
94 | template<typename Typelist, typename T> | |
95 | struct contains; | |
f910786b | 96 | |
fd1e1726 BK |
97 | template<typename Typelist, template<typename T> class Pred> |
98 | struct filter; | |
99 | ||
100 | template<typename Typelist, int i> | |
101 | struct at_index; | |
102 | ||
fd1e1726 BK |
103 | template<typename Typelist, template<typename T> class Transform> |
104 | struct transform; | |
d7f245b1 BK |
105 | |
106 | template<typename Typelist_Typelist> | |
107 | struct flatten; | |
108 | ||
109 | template<typename Typelist> | |
110 | struct from_first; | |
111 | ||
112 | template<typename T1> | |
113 | struct create1; | |
114 | ||
115 | template<typename T1, typename T2> | |
116 | struct create2; | |
117 | ||
118 | template<typename T1, typename T2, typename T3> | |
119 | struct create3; | |
120 | ||
121 | template<typename T1, typename T2, typename T3, typename T4> | |
122 | struct create4; | |
123 | ||
124 | template<typename T1, typename T2, typename T3, typename T4, typename T5> | |
125 | struct create5; | |
126 | ||
f910786b | 127 | template<typename T1, typename T2, typename T3, |
d7f245b1 BK |
128 | typename T4, typename T5, typename T6> |
129 | struct create6; | |
fd1e1726 | 130 | |
fd1e1726 BK |
131 | namespace detail |
132 | { | |
fd1e1726 BK |
133 | template<typename Fn, typename Typelist_Chain> |
134 | struct apply_; | |
135 | ||
136 | template<typename Fn, typename Hd, typename Tl> | |
137 | struct apply_<Fn, chain<Hd, Tl> > | |
138 | { | |
139 | void | |
d466a7e2 | 140 | operator()(Fn& f) |
fd1e1726 | 141 | { |
3441f106 | 142 | f.operator()(Hd()); |
fd1e1726 BK |
143 | apply_<Fn, Tl> next; |
144 | next(f); | |
145 | } | |
d466a7e2 | 146 | }; |
fd1e1726 BK |
147 | |
148 | template<typename Fn> | |
149 | struct apply_<Fn, null_type> | |
150 | { | |
151 | void | |
152 | operator()(Fn&) { } | |
d466a7e2 BK |
153 | }; |
154 | ||
155 | template<typename Gn, typename Typelist_Chain> | |
156 | struct apply_generator1_; | |
157 | ||
158 | template<typename Gn, typename Hd, typename Tl> | |
159 | struct apply_generator1_<Gn, chain<Hd, Tl> > | |
160 | { | |
161 | void | |
162 | operator()(Gn& g) | |
163 | { | |
164 | g.template operator()<Hd>(); | |
165 | apply_generator1_<Gn, Tl> next; | |
166 | next(g); | |
167 | } | |
168 | }; | |
169 | ||
170 | template<typename Gn> | |
171 | struct apply_generator1_<Gn, null_type> | |
172 | { | |
173 | void | |
174 | operator()(Gn&) { } | |
175 | }; | |
176 | ||
177 | template<typename Gn, typename TypelistT_Chain, typename TypelistV_Chain> | |
178 | struct apply_generator2_; | |
179 | ||
180 | template<typename Gn, typename Hd1, typename TlT, typename Hd2, typename TlV> | |
181 | struct apply_generator2_<Gn, chain<Hd1, TlT>, chain<Hd2, TlV> > | |
182 | { | |
183 | void | |
184 | operator()(Gn& g) | |
185 | { | |
186 | g.template operator()<Hd1, Hd2>(); | |
187 | apply_generator2_<Gn, TlT, TlV> next; | |
188 | next(g); | |
189 | } | |
190 | }; | |
191 | ||
192 | template<typename Gn> | |
193 | struct apply_generator2_<Gn, null_type, null_type> | |
194 | { | |
195 | void | |
196 | operator()(Gn&) { } | |
197 | }; | |
fd1e1726 | 198 | |
fd1e1726 BK |
199 | template<typename Typelist_Chain0, typename Typelist_Chain1> |
200 | struct append_; | |
201 | ||
202 | template<typename Hd, typename Tl, typename Typelist_Chain> | |
203 | struct append_<chain<Hd, Tl>, Typelist_Chain> | |
204 | { | |
d7f245b1 BK |
205 | private: |
206 | typedef append_<Tl, Typelist_Chain> append_type; | |
207 | ||
208 | public: | |
209 | typedef chain<Hd, typename append_type::type> type; | |
fd1e1726 BK |
210 | }; |
211 | ||
212 | template<typename Typelist_Chain> | |
213 | struct append_<null_type, Typelist_Chain> | |
d7f245b1 BK |
214 | { |
215 | typedef Typelist_Chain type; | |
216 | }; | |
217 | ||
218 | template<typename Typelist_Chain> | |
219 | struct append_<Typelist_Chain, null_type> | |
fd1e1726 BK |
220 | { |
221 | typedef Typelist_Chain type; | |
222 | }; | |
223 | ||
d7f245b1 BK |
224 | template<> |
225 | struct append_<null_type, null_type> | |
226 | { | |
227 | typedef null_type type; | |
228 | }; | |
229 | ||
230 | template<typename Typelist_Typelist_Chain> | |
231 | struct append_typelist_; | |
232 | ||
233 | template<typename Hd> | |
234 | struct append_typelist_<chain<Hd, null_type> > | |
235 | { | |
236 | typedef chain<Hd, null_type> type; | |
237 | }; | |
238 | ||
239 | template<typename Hd, typename Tl> | |
240 | struct append_typelist_<chain< Hd, Tl> > | |
241 | { | |
242 | private: | |
243 | typedef typename append_typelist_<Tl>::type rest_type; | |
f910786b | 244 | |
d7f245b1 BK |
245 | public: |
246 | typedef typename append<Hd, node<rest_type> >::type::root type; | |
247 | }; | |
248 | ||
fd1e1726 BK |
249 | template<typename Typelist_Chain, typename T> |
250 | struct contains_; | |
251 | ||
252 | template<typename T> | |
253 | struct contains_<null_type, T> | |
254 | { | |
255 | enum | |
256 | { | |
257 | value = false | |
258 | }; | |
259 | }; | |
260 | ||
261 | template<typename Hd, typename Tl, typename T> | |
262 | struct contains_<chain<Hd, Tl>, T> | |
263 | { | |
264 | enum | |
265 | { | |
266 | value = contains_<Tl, T>::value | |
267 | }; | |
268 | }; | |
f910786b | 269 | |
fd1e1726 BK |
270 | template<typename Tl, typename T> |
271 | struct contains_<chain<T, Tl>, T> | |
272 | { | |
273 | enum | |
274 | { | |
275 | value = true | |
276 | }; | |
277 | }; | |
278 | ||
fd1e1726 BK |
279 | template<typename Typelist_Chain, template<typename T> class Pred> |
280 | struct chain_filter_; | |
281 | ||
282 | template<template<typename T> class Pred> | |
283 | struct chain_filter_<null_type, Pred> | |
284 | { | |
d7f245b1 | 285 | typedef null_type type; |
fd1e1726 BK |
286 | }; |
287 | ||
288 | template<typename Hd, typename Tl, template<typename T> class Pred> | |
289 | struct chain_filter_<chain<Hd, Tl>, Pred> | |
290 | { | |
d7f245b1 | 291 | private: |
fd1e1726 BK |
292 | enum |
293 | { | |
294 | include_hd = Pred<Hd>::value | |
295 | }; | |
f910786b | 296 | |
d7f245b1 BK |
297 | typedef typename chain_filter_<Tl, Pred>::type rest_type; |
298 | typedef chain<Hd, rest_type> chain_type; | |
299 | ||
300 | public: | |
cbe5ba46 | 301 | typedef typename __conditional_type<include_hd, chain_type, rest_type>::__type type; |
fd1e1726 BK |
302 | }; |
303 | ||
fd1e1726 BK |
304 | template<typename Typelist_Chain, int i> |
305 | struct chain_at_index_; | |
306 | ||
307 | template<typename Hd, typename Tl> | |
308 | struct chain_at_index_<chain<Hd, Tl>, 0> | |
309 | { | |
310 | typedef Hd type; | |
311 | }; | |
f910786b | 312 | |
fd1e1726 BK |
313 | template<typename Hd, typename Tl, int i> |
314 | struct chain_at_index_<chain<Hd, Tl>, i> | |
315 | { | |
d7f245b1 | 316 | typedef typename chain_at_index_<Tl, i - 1>::type type; |
fd1e1726 BK |
317 | }; |
318 | ||
fd1e1726 BK |
319 | template<class Typelist_Chain, template<typename T> class Transform> |
320 | struct chain_transform_; | |
321 | ||
322 | template<template<typename T> class Transform> | |
323 | struct chain_transform_<null_type, Transform> | |
324 | { | |
d7f245b1 | 325 | typedef null_type type; |
fd1e1726 | 326 | }; |
f910786b | 327 | |
fd1e1726 BK |
328 | template<class Hd, class Tl, template<typename T> class Transform> |
329 | struct chain_transform_<chain<Hd, Tl>, Transform> | |
330 | { | |
d7f245b1 BK |
331 | private: |
332 | typedef typename chain_transform_<Tl, Transform>::type rest_type; | |
333 | typedef typename Transform<Hd>::type transform_type; | |
334 | ||
335 | public: | |
336 | typedef chain<transform_type, rest_type> type; | |
fd1e1726 BK |
337 | }; |
338 | ||
fd1e1726 | 339 | template<typename Typelist_Typelist_Chain> |
d7f245b1 | 340 | struct chain_flatten_; |
fd1e1726 | 341 | |
d7f245b1 | 342 | template<typename Hd_Tl> |
d466a7e2 BK |
343 | struct chain_flatten_<chain<Hd_Tl, null_type> > |
344 | { | |
345 | typedef typename Hd_Tl::root type; | |
346 | }; | |
fd1e1726 | 347 | |
d7f245b1 | 348 | template<typename Hd_Typelist, class Tl_Typelist> |
d466a7e2 BK |
349 | struct chain_flatten_<chain<Hd_Typelist, Tl_Typelist> > |
350 | { | |
351 | private: | |
352 | typedef typename chain_flatten_<Tl_Typelist>::type rest_type; | |
353 | typedef append<Hd_Typelist, node<rest_type> > append_type; | |
354 | public: | |
355 | typedef typename append_type::type::root type; | |
356 | }; | |
fd1e1726 | 357 | } // namespace detail |
3cbc7af0 | 358 | |
d7f245b1 BK |
359 | #define _GLIBCXX_TYPELIST_CHAIN1(X0) __gnu_cxx::typelist::chain<X0, __gnu_cxx::typelist::null_type> |
360 | #define _GLIBCXX_TYPELIST_CHAIN2(X0, X1) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN1(X1) > | |
361 | #define _GLIBCXX_TYPELIST_CHAIN3(X0, X1, X2) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN2(X1, X2) > | |
362 | #define _GLIBCXX_TYPELIST_CHAIN4(X0, X1, X2, X3) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN3(X1, X2, X3) > | |
363 | #define _GLIBCXX_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN4(X1, X2, X3, X4) > | |
364 | #define _GLIBCXX_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) > | |
365 | #define _GLIBCXX_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) > | |
366 | #define _GLIBCXX_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN7(X1, X2, X3, X4, X5, X6, X7) > | |
367 | #define _GLIBCXX_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN8(X1, X2, X3, X4, X5, X6, X7, X8) > | |
368 | #define _GLIBCXX_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN9(X1, X2, X3, X4, X5, X6, X7, X8, X9) > | |
369 | #define _GLIBCXX_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN10(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) > | |
370 | #define _GLIBCXX_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN11(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) > | |
371 | #define _GLIBCXX_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN12(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) > | |
372 | #define _GLIBCXX_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN13(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) > | |
373 | #define _GLIBCXX_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN14(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) > | |
12bfa8bd PC |
374 | #define _GLIBCXX_TYPELIST_CHAIN16(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN15(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15) > |
375 | #define _GLIBCXX_TYPELIST_CHAIN17(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN16(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16) > | |
376 | #define _GLIBCXX_TYPELIST_CHAIN18(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN17(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17) > | |
377 | #define _GLIBCXX_TYPELIST_CHAIN19(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN18(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18) > | |
378 | #define _GLIBCXX_TYPELIST_CHAIN20(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18, X19) __gnu_cxx::typelist::chain<X0, _GLIBCXX_TYPELIST_CHAIN19(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18, X19) > | |
3cbc7af0 | 379 | |
d466a7e2 | 380 | template<typename Fn, typename Typelist> |
d7f245b1 BK |
381 | void |
382 | apply(Fn& fn, Typelist) | |
fd1e1726 | 383 | { |
d7f245b1 BK |
384 | detail::apply_<Fn, typename Typelist::root> a; |
385 | a(fn); | |
386 | } | |
fd1e1726 | 387 | |
d466a7e2 BK |
388 | template<typename Fn, typename Typelist> |
389 | void | |
390 | apply_generator(Fn& fn, Typelist) | |
391 | { | |
392 | detail::apply_generator1_<Fn, typename Typelist::root> a; | |
393 | a(fn); | |
394 | } | |
395 | ||
396 | template<typename Fn, typename TypelistT, typename TypelistV> | |
397 | void | |
398 | apply_generator(Fn& fn, TypelistT, TypelistV) | |
399 | { | |
400 | typedef typename TypelistT::root rootT; | |
401 | typedef typename TypelistV::root rootV; | |
402 | detail::apply_generator2_<Fn, rootT, rootV> a; | |
403 | a(fn); | |
404 | } | |
405 | ||
fd1e1726 BK |
406 | template<typename Typelist0, typename Typelist1> |
407 | struct append | |
408 | { | |
409 | private: | |
410 | typedef typename Typelist0::root root0_type; | |
411 | typedef typename Typelist1::root root1_type; | |
412 | typedef detail::append_<root0_type, root1_type> append_type; | |
413 | ||
414 | public: | |
d7f245b1 | 415 | typedef node<typename append_type::type> type; |
fd1e1726 BK |
416 | }; |
417 | ||
418 | template<typename Typelist_Typelist> | |
cad367a6 | 419 | struct append_typelist |
fd1e1726 BK |
420 | { |
421 | private: | |
422 | typedef typename Typelist_Typelist::root root_type; | |
cad367a6 | 423 | typedef detail::append_typelist_<root_type> append_type; |
fd1e1726 BK |
424 | |
425 | public: | |
d7f245b1 | 426 | typedef node<typename append_type::type> type; |
fd1e1726 BK |
427 | }; |
428 | ||
429 | template<typename Typelist, typename T> | |
430 | struct contains | |
431 | { | |
d7f245b1 | 432 | private: |
fd1e1726 BK |
433 | typedef typename Typelist::root root_type; |
434 | ||
d7f245b1 | 435 | public: |
fd1e1726 BK |
436 | enum |
437 | { | |
438 | value = detail::contains_<root_type, T>::value | |
439 | }; | |
440 | }; | |
441 | ||
442 | template<typename Typelist, template<typename T> class Pred> | |
443 | struct filter | |
444 | { | |
445 | private: | |
446 | typedef typename Typelist::root root_type; | |
447 | typedef detail::chain_filter_<root_type, Pred> filter_type; | |
448 | ||
449 | public: | |
d7f245b1 | 450 | typedef node<typename filter_type::type> type; |
fd1e1726 BK |
451 | }; |
452 | ||
453 | template<typename Typelist, int i> | |
454 | struct at_index | |
455 | { | |
d7f245b1 | 456 | private: |
fd1e1726 BK |
457 | typedef typename Typelist::root root_type; |
458 | typedef detail::chain_at_index_<root_type, i> index_type; | |
f910786b | 459 | |
d7f245b1 | 460 | public: |
fd1e1726 BK |
461 | typedef typename index_type::type type; |
462 | }; | |
463 | ||
464 | template<typename Typelist, template<typename T> class Transform> | |
465 | struct transform | |
466 | { | |
467 | private: | |
468 | typedef typename Typelist::root root_type; | |
469 | typedef detail::chain_transform_<root_type, Transform> transform_type; | |
470 | ||
471 | public: | |
cad367a6 | 472 | typedef node<typename transform_type::type> type; |
fd1e1726 | 473 | }; |
d7f245b1 BK |
474 | |
475 | template<typename Typelist_Typelist> | |
476 | struct flatten | |
477 | { | |
478 | private: | |
479 | typedef typename Typelist_Typelist::root root_type; | |
480 | typedef typename detail::chain_flatten_<root_type>::type flatten_type; | |
481 | ||
482 | public: | |
483 | typedef node<flatten_type> type; | |
484 | }; | |
485 | ||
486 | template<typename Typelist> | |
487 | struct from_first | |
488 | { | |
489 | private: | |
490 | typedef typename at_index<Typelist, 0>::type first_type; | |
491 | ||
492 | public: | |
493 | typedef node<chain<first_type, null_type> > type; | |
494 | }; | |
495 | ||
496 | template<typename T1> | |
497 | struct create1 | |
498 | { | |
499 | typedef node<_GLIBCXX_TYPELIST_CHAIN1(T1)> type; | |
500 | }; | |
501 | ||
502 | template<typename T1, typename T2> | |
503 | struct create2 | |
504 | { | |
505 | typedef node<_GLIBCXX_TYPELIST_CHAIN2(T1,T2)> type; | |
506 | }; | |
507 | ||
508 | template<typename T1, typename T2, typename T3> | |
509 | struct create3 | |
510 | { | |
511 | typedef node<_GLIBCXX_TYPELIST_CHAIN3(T1,T2,T3)> type; | |
512 | }; | |
513 | ||
514 | template<typename T1, typename T2, typename T3, typename T4> | |
515 | struct create4 | |
516 | { | |
517 | typedef node<_GLIBCXX_TYPELIST_CHAIN4(T1,T2,T3,T4)> type; | |
518 | }; | |
519 | ||
f910786b | 520 | template<typename T1, typename T2, typename T3, |
d7f245b1 BK |
521 | typename T4, typename T5> |
522 | struct create5 | |
523 | { | |
524 | typedef node<_GLIBCXX_TYPELIST_CHAIN5(T1,T2,T3,T4,T5)> type; | |
525 | }; | |
526 | ||
f910786b | 527 | template<typename T1, typename T2, typename T3, |
d7f245b1 BK |
528 | typename T4, typename T5, typename T6> |
529 | struct create6 | |
530 | { | |
531 | typedef node<_GLIBCXX_TYPELIST_CHAIN6(T1,T2,T3,T4,T5,T6)> type; | |
532 | }; | |
cad367a6 | 533 | } // namespace typelist |
12ffa228 BK |
534 | _GLIBCXX_END_NAMESPACE_VERSION |
535 | } // namespace | |
fd1e1726 BK |
536 | |
537 | ||
fd1e1726 | 538 | #endif |