Import a stripped down version of gcc-4.1.1
[dragonfly.git] / contrib / gcc-4.1 / libstdc++-v3 / include / ext / pb_assoc / detail / typelist.hpp
1 // -*- C++ -*-
2
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.
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
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.
20
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.
29
30 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
31
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.
39
40 /**
41  * @file typelist.hpp
42  * Contains typelist_chain definitions.
43  * Typelists are an idea by Andrei Alexandrescu.
44  */
45
46 #ifndef TYPELIST_HPP
47 #define TYPELIST_HPP
48
49 #ifdef _MSC_VER
50 #pragma warning(disable: 4503)
51 #endif // #ifdef _MSC_VER
52
53 #include <ext/pb_assoc/detail/type_utils.hpp>
54
55 namespace pb_assoc
56 {
57
58   namespace detail
59   {
60
61     struct null_type
62     { };
63
64     template<typename Hd, typename Tl>
65     struct typelist_chain
66     {
67       typedef Hd head;
68
69       typedef Tl tail;
70     };
71
72     template<class Root>
73     struct typelist
74     {
75       typedef Root root;
76     };
77
78 #define PB_ASSOC_TYPELIST_CHAIN1(X0) pb_assoc::detail::typelist_chain<X0, pb_assoc::detail::null_type>
79 #define PB_ASSOC_TYPELIST_CHAIN2(X0, X1) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN1(X1) >
80 #define PB_ASSOC_TYPELIST_CHAIN3(X0, X1, X2) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN2(X1, X2) >
81 #define PB_ASSOC_TYPELIST_CHAIN4(X0, X1, X2, X3) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN3(X1, X2, X3) >
82 #define PB_ASSOC_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN4(X1, X2, X3, X4) >
83 #define PB_ASSOC_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) >
84 #define PB_ASSOC_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) >
85 #define PB_ASSOC_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN7(X1, X2, X3, X4, X5, X6, X7) >
86 #define PB_ASSOC_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN8(X1, X2, X3, X4, X5, X6, X7, X8) >
87 #define PB_ASSOC_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN9(X1, X2, X3, X4, X5, X6, X7, X8, X9) >
88 #define PB_ASSOC_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN10(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) >
89 #define PB_ASSOC_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN11(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) >
90 #define PB_ASSOC_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN12(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) >
91 #define PB_ASSOC_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN13(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) >
92 #define PB_ASSOC_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) pb_assoc::detail::typelist_chain<X0, PB_ASSOC_TYPELIST_CHAIN14(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) >
93
94 #include <ext/pb_assoc/detail/typelist/typelist_apply.hpp>
95
96     template<class Fn, class Typelist>
97     void
98     typelist_apply(Fn& r_fn, Typelist /*tl*/)
99     {
100       detail::apply_<
101         Fn,
102         typename Typelist::root>
103         a;
104
105       a(r_fn);
106     }
107
108 #include <ext/pb_assoc/detail/typelist/typelist_append.hpp>
109
110     template<class Typelist0, class Typelist1>
111     struct typelist_append
112     {
113     private:
114       typedef
115       typename detail::typelist_append_<
116         typename Typelist0::root,
117         typename Typelist1::root>::type
118       res_hd;
119
120     public:
121       typedef typelist< res_hd> type;
122     };
123
124 #include <ext/pb_assoc/detail/typelist/typelist_typelist_append.hpp>
125
126     template<class Typelist_Typelist>
127     struct typelist_typelist_append
128     {
129     private:
130       typedef
131       typename detail::typelist_typelist_append_<
132         typename Typelist_Typelist::root>::type
133       res_hd;
134
135     public:
136       typedef typelist< res_hd> type;
137     };
138
139 #include <ext/pb_assoc/detail/typelist/typelist_contains.hpp>
140
141     template<class Typelist, class T>
142     struct typelist_contains
143     {
144       enum
145         {
146           value =
147           detail::typelist_contains_<
148           typename Typelist::root,
149           T>::value
150         };
151     };
152
153 #include <ext/pb_assoc/detail/typelist/typelist_filter.hpp>
154
155     template<class Typelist, template<typename T>
156     class Pred>
157     struct typelist_filter
158     {
159     private:
160       typedef
161       typename detail::typelist_chain_filter_<
162         typename Typelist::root,
163         Pred>::type
164       root_type;
165
166     public:
167       typedef typelist< root_type> type;
168     };
169
170 #include <ext/pb_assoc/detail/typelist/typelist_at_index.hpp>
171
172     template<class Typelist, int i>
173     struct typelist_at_index
174     {
175       typedef
176       typename detail::typelist_chain_at_index_<
177         typename Typelist::root,
178         i>::type
179       type;
180     };
181
182 #include <ext/pb_assoc/detail/typelist/typelist_transform.hpp>
183
184     template<class Typelist, template<class T>
185     class Transform>
186     struct typelist_transform
187     {
188     private:
189       typedef
190       typename detail::typelist_chain_transform_<
191         typename Typelist::root,
192         Transform>::type
193       root_type;
194
195     public:
196       typedef typelist< root_type> type;
197     };
198
199 #undef PB_ASSOC_TYPELIST_CHAIN1
200 #undef PB_ASSOC_TYPELIST_CHAIN2
201 #undef PB_ASSOC_TYPELIST_CHAIN3
202 #undef PB_ASSOC_TYPELIST_CHAIN4
203 #undef PB_ASSOC_TYPELIST_CHAIN5
204 #undef PB_ASSOC_TYPELIST_CHAIN6
205 #undef PB_ASSOC_TYPELIST_CHAIN7
206 #undef PB_ASSOC_TYPELIST_CHAIN8
207 #undef PB_ASSOC_TYPELIST_CHAIN9
208 #undef PB_ASSOC_TYPELIST_CHAIN10
209 #undef PB_ASSOC_TYPELIST_CHAIN11
210 #undef PB_ASSOC_TYPELIST_CHAIN12
211 #undef PB_ASSOC_TYPELIST_CHAIN13
212 #undef PB_ASSOC_TYPELIST_CHAIN14
213 #undef PB_ASSOC_TYPELIST_CHAIN15
214
215   } // namespace detail
216
217 } // namespace pb_assoc
218
219 #endif // #ifndef TYPELIST_HPP
220