3 // Copyright (C) 2005, 2006 Free Software Foundation, Inc.
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 terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 2, or (at your option) any later
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19 // MA 02111-1307, USA.
21 // As a special exception, you may use this file as part of a free
22 // software library without restriction. Specifically, if other files
23 // instantiate templates or use macros or inline functions from this
24 // file, or you compile this file and link it with other files to
25 // produce an executable, this file does not by itself cause the
26 // resulting executable to be covered by the GNU General Public
27 // License. This exception does not however invalidate any other
28 // reasons why the executable file might be covered by the GNU General
31 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
33 // Permission to use, copy, modify, sell, and distribute this software
34 // is hereby granted without fee, provided that the above copyright
35 // notice appears in all copies, and that both that copyright notice
36 // and this permission notice appear in supporting documentation. None
37 // of the above authors, nor IBM Haifa Research Laboratories, make any
38 // representation about the suitability of this software for any
39 // purpose. It is provided "as is" without express or implied
44 * Contains typelist_chain definitions.
45 * Typelists are an idea by Andrei Alexandrescu.
48 #ifndef PB_DS_TYPELIST_HPP
49 #define PB_DS_TYPELIST_HPP
51 #include <ext/pb_ds/detail/type_utils.hpp>
60 template<typename Hd, typename Tl>
67 template<typename Root>
73 #define PB_DS_TYPELIST_CHAIN1(X0) typelist_chain<X0, null_type>
74 #define PB_DS_TYPELIST_CHAIN2(X0, X1) typelist_chain<X0, PB_DS_TYPELIST_CHAIN1(X1) >
75 #define PB_DS_TYPELIST_CHAIN3(X0, X1, X2) typelist_chain<X0, PB_DS_TYPELIST_CHAIN2(X1, X2) >
76 #define PB_DS_TYPELIST_CHAIN4(X0, X1, X2, X3) typelist_chain<X0, PB_DS_TYPELIST_CHAIN3(X1, X2, X3) >
77 #define PB_DS_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) typelist_chain<X0, PB_DS_TYPELIST_CHAIN4(X1, X2, X3, X4) >
78 #define PB_DS_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) typelist_chain<X0, PB_DS_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) >
79 #define PB_DS_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) typelist_chain<X0, PB_DS_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) >
80 #define PB_DS_TYPELIST_CHAIN8(X0, X1, X2, X3, X4, X5, X6, X7) typelist_chain<X0, PB_DS_TYPELIST_CHAIN7(X1, X2, X3, X4, X5, X6, X7) >
81 #define PB_DS_TYPELIST_CHAIN9(X0, X1, X2, X3, X4, X5, X6, X7, X8) typelist_chain<X0, PB_DS_TYPELIST_CHAIN8(X1, X2, X3, X4, X5, X6, X7, X8) >
82 #define PB_DS_TYPELIST_CHAIN10(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) typelist_chain<X0, PB_DS_TYPELIST_CHAIN9(X1, X2, X3, X4, X5, X6, X7, X8, X9) >
83 #define PB_DS_TYPELIST_CHAIN11(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) typelist_chain<X0, PB_DS_TYPELIST_CHAIN10(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) >
84 #define PB_DS_TYPELIST_CHAIN12(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) typelist_chain<X0, PB_DS_TYPELIST_CHAIN11(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) >
85 #define PB_DS_TYPELIST_CHAIN13(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) typelist_chain<X0, PB_DS_TYPELIST_CHAIN12(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) >
86 #define PB_DS_TYPELIST_CHAIN14(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) typelist_chain<X0, PB_DS_TYPELIST_CHAIN13(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) >
87 #define PB_DS_TYPELIST_CHAIN15(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) typelist_chain<X0, PB_DS_TYPELIST_CHAIN14(X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) >
89 #include <ext/pb_ds/detail/typelist/typelist_apply.hpp>
91 template<typename Fn, class Typelist>
93 typelist_apply(Fn& r_fn, Typelist)
95 detail::apply_<Fn, typename Typelist::root> a;
99 #include <ext/pb_ds/detail/typelist/typelist_append.hpp>
101 template<typename Typelist0, class Typelist1>
102 struct typelist_append
106 typename detail::typelist_append_<
107 typename Typelist0::root,
108 typename Typelist1::root>::type
112 typedef typelist< res_hd> type;
115 #include <ext/pb_ds/detail/typelist/typelist_typelist_append.hpp>
117 template<typename Typelist_Typelist>
118 struct typelist_typelist_append
122 typename detail::typelist_typelist_append_<
123 typename Typelist_Typelist::root>::type
127 typedef typelist< res_hd> type;
130 #include <ext/pb_ds/detail/typelist/typelist_contains.hpp>
132 template<typename Typelist, typename T>
133 struct typelist_contains
138 detail::typelist_contains_<
139 typename Typelist::root,
144 #include <ext/pb_ds/detail/typelist/typelist_filter.hpp>
146 template<typename Typelist, template<typename T>
148 struct typelist_filter
152 typename detail::typelist_chain_filter_<
153 typename Typelist::root,
158 typedef typelist< root_type> type;
161 #include <ext/pb_ds/detail/typelist/typelist_at_index.hpp>
163 template<typename Typelist, int i>
164 struct typelist_at_index
167 typename detail::typelist_chain_at_index_<
168 typename Typelist::root,
173 #include <ext/pb_ds/detail/typelist/typelist_transform.hpp>
175 template<typename Typelist, template<typename T>
177 struct typelist_transform
181 typename detail::typelist_chain_transform_<
182 typename Typelist::root,
187 typedef typelist< root_type> type;
190 #include <ext/pb_ds/detail/typelist/typelist_flatten.hpp>
192 template<typename Typelist_Typelist>
193 struct typelist_flatten
197 typename detail::typelist_chain_flatten_<
198 typename Typelist_Typelist::root>::type
202 typedef typelist< root_type> type;
205 template<typename Typelist>
206 struct typelist_from_first
209 typedef typename typelist_at_index< Typelist, 0>::type first_type;
212 typedef typelist< typelist_chain< first_type, null_type> > type;
215 template<typename T0>
218 typedef typelist< PB_DS_TYPELIST_CHAIN1( T0)> type;
221 template<typename T0, typename T1>
226 PB_DS_TYPELIST_CHAIN2( T0, T1)>
230 template<typename T0, typename T1, typename T2>
235 PB_DS_TYPELIST_CHAIN3( T0, T1, T2)>
239 template<typename T0, typename T1, typename T2, typename T3>
244 PB_DS_TYPELIST_CHAIN4( T0, T1, T2, T3)>
248 template<typename T0,
257 PB_DS_TYPELIST_CHAIN5( T0, T1, T2, T3, T4)>
261 template<typename T0,
271 PB_DS_TYPELIST_CHAIN6( T0, T1, T2, T3, T4, T5)>
275 #undef PB_DS_TYPELIST_CHAIN1
276 #undef PB_DS_TYPELIST_CHAIN2
277 #undef PB_DS_TYPELIST_CHAIN3
278 #undef PB_DS_TYPELIST_CHAIN4
279 #undef PB_DS_TYPELIST_CHAIN5
280 #undef PB_DS_TYPELIST_CHAIN6
281 #undef PB_DS_TYPELIST_CHAIN7
282 #undef PB_DS_TYPELIST_CHAIN8
283 #undef PB_DS_TYPELIST_CHAIN9
284 #undef PB_DS_TYPELIST_CHAIN10
285 #undef PB_DS_TYPELIST_CHAIN11
286 #undef PB_DS_TYPELIST_CHAIN12
287 #undef PB_DS_TYPELIST_CHAIN13
288 #undef PB_DS_TYPELIST_CHAIN14
289 #undef PB_DS_TYPELIST_CHAIN15
291 } // namespace detail
295 #endif // #ifndef PB_DS_TYPELIST_HPP