Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / include / ext / pb_assoc / detail / typelist.hpp
blob08f50c81848ed0b7478a4516009a379878a0821e
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.hpp
42 * Contains typelist_chain definitions.
43 * Typelists are an idea by Andrei Alexandrescu.
46 #ifndef TYPELIST_HPP
47 #define TYPELIST_HPP
49 #ifdef _MSC_VER
50 #pragma warning(disable: 4503)
51 #endif // #ifdef _MSC_VER
53 #include <ext/pb_assoc/detail/type_utils.hpp>
55 namespace pb_assoc
58 namespace detail
61 struct null_type
62 { };
64 template<typename Hd, typename Tl>
65 struct typelist_chain
67 typedef Hd head;
69 typedef Tl tail;
72 template<class Root>
73 struct typelist
75 typedef Root root;
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) >
94 #include <ext/pb_assoc/detail/typelist/typelist_apply.hpp>
96 template<class Fn, class Typelist>
97 void
98 typelist_apply(Fn& r_fn, Typelist /*tl*/)
100 detail::apply_<
102 typename Typelist::root>
105 a(r_fn);
108 #include <ext/pb_assoc/detail/typelist/typelist_append.hpp>
110 template<class Typelist0, class Typelist1>
111 struct typelist_append
113 private:
114 typedef
115 typename detail::typelist_append_<
116 typename Typelist0::root,
117 typename Typelist1::root>::type
118 res_hd;
120 public:
121 typedef typelist< res_hd> type;
124 #include <ext/pb_assoc/detail/typelist/typelist_typelist_append.hpp>
126 template<class Typelist_Typelist>
127 struct typelist_typelist_append
129 private:
130 typedef
131 typename detail::typelist_typelist_append_<
132 typename Typelist_Typelist::root>::type
133 res_hd;
135 public:
136 typedef typelist< res_hd> type;
139 #include <ext/pb_assoc/detail/typelist/typelist_contains.hpp>
141 template<class Typelist, class T>
142 struct typelist_contains
144 enum
146 value =
147 detail::typelist_contains_<
148 typename Typelist::root,
149 T>::value
153 #include <ext/pb_assoc/detail/typelist/typelist_filter.hpp>
155 template<class Typelist, template<typename T>
156 class Pred>
157 struct typelist_filter
159 private:
160 typedef
161 typename detail::typelist_chain_filter_<
162 typename Typelist::root,
163 Pred>::type
164 root_type;
166 public:
167 typedef typelist< root_type> type;
170 #include <ext/pb_assoc/detail/typelist/typelist_at_index.hpp>
172 template<class Typelist, int i>
173 struct typelist_at_index
175 typedef
176 typename detail::typelist_chain_at_index_<
177 typename Typelist::root,
178 i>::type
179 type;
182 #include <ext/pb_assoc/detail/typelist/typelist_transform.hpp>
184 template<class Typelist, template<class T>
185 class Transform>
186 struct typelist_transform
188 private:
189 typedef
190 typename detail::typelist_chain_transform_<
191 typename Typelist::root,
192 Transform>::type
193 root_type;
195 public:
196 typedef typelist< root_type> type;
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
215 } // namespace detail
217 } // namespace pb_assoc
219 #endif // #ifndef TYPELIST_HPP