toolchain: switch kernel 2.4 builds to gcc 4.2.4
[tomato.git] / tools / brcm / K24 / hndtools-mipsel-uclibc-4.1.2 / include / c++ / 4.1.2 / ext / typelist.h
blob5bd7c9db699936af22c795326de1b45eb5fc1cb3
1 // -*- C++ -*-
3 // Copyright (C) 2005 Free Software Foundation, Inc.
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
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32 // Permission to use, copy, modify, sell, and distribute this software
33 // is hereby granted without fee, provided that the above copyright
34 // notice appears in all copies, and that both that copyright notice and
35 // this permission notice appear in supporting documentation. None of
36 // the above authors, nor IBM Haifa Research Laboratories, make any
37 // representation about the suitability of this software for any
38 // purpose. It is provided "as is" without express or implied warranty.
40 /**
41 * @file typelist.h
42 * Contains typelist_chain definitions.
43 * Typelists are an idea by Andrei Alexandrescu.
46 #ifndef TYPELIST_HPP
47 #define TYPELIST_HPP
49 namespace __gnu_cxx
51 // XXX namespace typelist
52 // struct typelist -> struct node
54 struct null_type { };
56 template<typename Root>
57 struct typelist
59 typedef Root root;
62 // Forward declarations of functors.
63 template<typename Hd, typename Typelist>
64 struct chain
66 typedef Hd head;
67 typedef Typelist tail;
70 template<typename Typelist0, typename Typelist1>
71 struct append;
73 template<typename Typelist_Typelist>
74 struct typelist_append;
76 template<typename Typelist, typename T>
77 struct contains;
79 template<typename Typelist, template<typename T> class Pred>
80 struct filter;
82 template<typename Typelist, int i>
83 struct at_index;
85 template<typename Fn, typename Typelist>
86 struct apply;
88 template<typename Typelist, template<typename T> class Transform>
89 struct transform;
93 namespace __gnu_cxx
95 namespace detail
97 // #include <ext/detail/type_utils.h>
98 template<typename Type>
99 struct type_to_type
101 typedef Type type;
104 template<bool Cond, typename A, typename B>
105 struct cond_type;
107 template<typename A, typename B>
108 struct cond_type<true, A, B>
110 typedef A type;
113 template<typename A, typename B>
114 struct cond_type<false, A, B>
116 typedef B type;
119 // #include <ext/detail/apply.h>
120 template<typename Fn, typename Typelist_Chain>
121 struct apply_;
123 template<typename Fn, typename Hd, typename Tl>
124 struct apply_<Fn, chain<Hd, Tl> >
126 void
127 operator() (Fn& f)
129 f.operator()(type_to_type<Hd>());
130 apply_<Fn, Tl> next;
131 next(f);
135 template<typename Fn>
136 struct apply_<Fn, null_type>
138 void
139 operator()(Fn&) { }
142 // #include <ext/detail/append.h>
143 template<typename Typelist_Chain0, typename Typelist_Chain1>
144 struct append_;
146 template<typename Hd, typename Tl, typename Typelist_Chain>
147 struct append_<chain<Hd, Tl>, Typelist_Chain>
149 typedef append_<Tl, Typelist_Chain> append_type;
150 typedef chain<Hd, typename append_type::type> type;
153 template<typename Typelist_Chain>
154 struct append_<null_type, Typelist_Chain>
156 typedef Typelist_Chain type;
159 // #include <ext/detail/contains.h>
160 template<typename Typelist_Chain, typename T>
161 struct contains_;
163 template<typename T>
164 struct contains_<null_type, T>
166 enum
168 value = false
172 template<typename Hd, typename Tl, typename T>
173 struct contains_<chain<Hd, Tl>, T>
175 enum
177 value = contains_<Tl, T>::value
181 template<typename Tl, typename T>
182 struct contains_<chain<T, Tl>, T>
184 enum
186 value = true
190 // #include <ext/detail/filter.h>
191 template<typename Typelist_Chain, template<typename T> class Pred>
192 struct chain_filter_;
194 template<template<typename T> class Pred>
195 struct chain_filter_<null_type, Pred>
197 typedef null_type type;
200 template<typename Hd, typename Tl, template<typename T> class Pred>
201 struct chain_filter_<chain<Hd, Tl>, Pred>
203 enum
205 include_hd = Pred<Hd>::value
208 typedef typename chain_filter_<Tl, Pred>::type rest_type;
209 typedef chain<Hd, rest_type> chain_type;
210 typedef typename cond_type<include_hd, chain_type, rest_type>::type type;
213 // #include <ext/detail/at_index.h>
214 template<typename Typelist_Chain, int i>
215 struct chain_at_index_;
217 template<typename Hd, typename Tl>
218 struct chain_at_index_<chain<Hd, Tl>, 0>
220 typedef Hd type;
223 template<typename Hd, typename Tl, int i>
224 struct chain_at_index_<chain<Hd, Tl>, i>
226 typedef typename chain_at_index_<Tl, i - 1>::type type;
229 // #include <ext/detail/transform.h>
230 template<class Typelist_Chain, template<typename T> class Transform>
231 struct chain_transform_;
233 template<template<typename T> class Transform>
234 struct chain_transform_<null_type, Transform>
236 typedef null_type type;
239 template<class Hd, class Tl, template<typename T> class Transform>
240 struct chain_transform_<chain<Hd, Tl>, Transform>
242 typedef typename chain_transform_<Tl, Transform>::type rest_type;
243 typedef typename Transform<Hd>::type transform_type;
244 typedef chain<transform_type, rest_type> type;
247 // #include <ext/detail/typelist_append.h>
248 template<typename Typelist_Typelist_Chain>
249 struct typelist_append_;
251 template<typename Hd>
252 struct typelist_append_<chain<Hd, null_type> >
254 typedef chain<Hd, null_type> type;
257 template<typename Hd, typename Tl>
258 struct typelist_append_<chain< Hd, Tl> >
260 private:
261 typedef typename typelist_append_<Tl>::type rest;
263 public:
264 typedef typename append<Hd, typelist<rest> >::type::root type;
266 } // namespace detail
270 namespace __gnu_cxx
272 template<typename Fn, typename Typelist>
273 struct apply
275 void
276 operator()(Fn& f)
278 typedef typename Typelist::root root_type;
279 detail::apply_<Fn, root_type> a;
280 a(f);
284 template<typename Typelist0, typename Typelist1>
285 struct append
287 private:
288 typedef typename Typelist0::root root0_type;
289 typedef typename Typelist1::root root1_type;
290 typedef detail::append_<root0_type, root1_type> append_type;
292 public:
293 typedef typelist<typename append_type::type> type;
296 template<typename Typelist_Typelist>
297 struct typelist_append
299 private:
300 typedef typename Typelist_Typelist::root root_type;
301 typedef detail::typelist_append_<root_type> append_type;
303 public:
304 typedef typelist<typename append_type::type> type;
307 template<typename Typelist, typename T>
308 struct contains
310 typedef typename Typelist::root root_type;
312 enum
314 value = detail::contains_<root_type, T>::value
318 template<typename Typelist, template<typename T> class Pred>
319 struct filter
321 private:
322 typedef typename Typelist::root root_type;
323 typedef detail::chain_filter_<root_type, Pred> filter_type;
325 public:
326 typedef typelist<typename filter_type::type> type;
329 template<typename Typelist, int i>
330 struct at_index
332 typedef typename Typelist::root root_type;
333 typedef detail::chain_at_index_<root_type, i> index_type;
335 typedef typename index_type::type type;
338 template<typename Typelist, template<typename T> class Transform>
339 struct transform
341 private:
342 typedef typename Typelist::root root_type;
343 typedef detail::chain_transform_<root_type, Transform> transform_type;
345 public:
346 typedef typelist<typename transform_type::type> type;
348 } // namespace __gnu_cxx
351 #define _GLIBCXX_TYPELIST_CHAIN1(X0) __gnu_cxx::chain<X0, __gnu_cxx::null_type>
352 #define _GLIBCXX_TYPELIST_CHAIN2(X0, X1) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN1(X1) >
353 #define _GLIBCXX_TYPELIST_CHAIN3(X0, X1, X2) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN2(X1, X2) >
354 #define _GLIBCXX_TYPELIST_CHAIN4(X0, X1, X2, X3) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN3(X1, X2, X3) >
355 #define _GLIBCXX_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN4(X1, X2, X3, X4) >
356 #define _GLIBCXX_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) >
357 #define _GLIBCXX_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) >
358 #define _GLIBCXX_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN7(X1, X2, X3, X4, X5, X6, X7) >
359 #define _GLIBCXX_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN8(X1, X2, X3, X4, X5, X6, X7, X8) >
360 #define _GLIBCXX_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN9(X1, X2, X3, X4, X5, X6, X7, X8, X9) >
361 #define _GLIBCXX_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN10(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) >
362 #define _GLIBCXX_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN11(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) >
363 #define _GLIBCXX_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN12(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) >
364 #define _GLIBCXX_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN13(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) >
365 #define _GLIBCXX_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN14(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) >
367 #endif