00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00046 #ifndef TYPELIST_HPP
00047 #define TYPELIST_HPP
00048
00049 namespace __gnu_cxx
00050 {
00051
00052
00053
00054 struct null_type { };
00055
00056 template<typename Root>
00057 struct typelist
00058 {
00059 typedef Root root;
00060 };
00061
00062
00063 template<typename Hd, typename Typelist>
00064 struct chain
00065 {
00066 typedef Hd head;
00067 typedef Typelist tail;
00068 };
00069
00070 template<typename Typelist0, typename Typelist1>
00071 struct append;
00072
00073 template<typename Typelist_Typelist>
00074 struct typelist_append;
00075
00076 template<typename Typelist, typename T>
00077 struct contains;
00078
00079 template<typename Typelist, template<typename T> class Pred>
00080 struct filter;
00081
00082 template<typename Typelist, int i>
00083 struct at_index;
00084
00085 template<typename Fn, typename Typelist>
00086 struct apply;
00087
00088 template<typename Typelist, template<typename T> class Transform>
00089 struct transform;
00090 }
00091
00092
00093 namespace __gnu_cxx
00094 {
00095 namespace detail
00096 {
00097
00098 template<typename Type>
00099 struct type_to_type
00100 {
00101 typedef Type type;
00102 };
00103
00104 template<bool Cond, typename A, typename B>
00105 struct cond_type;
00106
00107 template<typename A, typename B>
00108 struct cond_type<true, A, B>
00109 {
00110 typedef A type;
00111 };
00112
00113 template<typename A, typename B>
00114 struct cond_type<false, A, B>
00115 {
00116 typedef B type;
00117 };
00118
00119
00120 template<typename Fn, typename Typelist_Chain>
00121 struct apply_;
00122
00123 template<typename Fn, typename Hd, typename Tl>
00124 struct apply_<Fn, chain<Hd, Tl> >
00125 {
00126 void
00127 operator() (Fn& f)
00128 {
00129 f.operator()(type_to_type<Hd>());
00130 apply_<Fn, Tl> next;
00131 next(f);
00132 }
00133 };
00134
00135 template<typename Fn>
00136 struct apply_<Fn, null_type>
00137 {
00138 void
00139 operator()(Fn&) { }
00140 };
00141
00142
00143 template<typename Typelist_Chain0, typename Typelist_Chain1>
00144 struct append_;
00145
00146 template<typename Hd, typename Tl, typename Typelist_Chain>
00147 struct append_<chain<Hd, Tl>, Typelist_Chain>
00148 {
00149 typedef append_<Tl, Typelist_Chain> append_type;
00150 typedef chain<Hd, typename append_type::type> type;
00151 };
00152
00153 template<typename Typelist_Chain>
00154 struct append_<null_type, Typelist_Chain>
00155 {
00156 typedef Typelist_Chain type;
00157 };
00158
00159
00160 template<typename Typelist_Chain, typename T>
00161 struct contains_;
00162
00163 template<typename T>
00164 struct contains_<null_type, T>
00165 {
00166 enum
00167 {
00168 value = false
00169 };
00170 };
00171
00172 template<typename Hd, typename Tl, typename T>
00173 struct contains_<chain<Hd, Tl>, T>
00174 {
00175 enum
00176 {
00177 value = contains_<Tl, T>::value
00178 };
00179 };
00180
00181 template<typename Tl, typename T>
00182 struct contains_<chain<T, Tl>, T>
00183 {
00184 enum
00185 {
00186 value = true
00187 };
00188 };
00189
00190
00191 template<typename Typelist_Chain, template<typename T> class Pred>
00192 struct chain_filter_;
00193
00194 template<template<typename T> class Pred>
00195 struct chain_filter_<null_type, Pred>
00196 {
00197 typedef null_type type;
00198 };
00199
00200 template<typename Hd, typename Tl, template<typename T> class Pred>
00201 struct chain_filter_<chain<Hd, Tl>, Pred>
00202 {
00203 enum
00204 {
00205 include_hd = Pred<Hd>::value
00206 };
00207
00208 typedef typename chain_filter_<Tl, Pred>::type rest_type;
00209 typedef chain<Hd, rest_type> chain_type;
00210 typedef typename cond_type<include_hd, chain_type, rest_type>::type type;
00211 };
00212
00213
00214 template<typename Typelist_Chain, int i>
00215 struct chain_at_index_;
00216
00217 template<typename Hd, typename Tl>
00218 struct chain_at_index_<chain<Hd, Tl>, 0>
00219 {
00220 typedef Hd type;
00221 };
00222
00223 template<typename Hd, typename Tl, int i>
00224 struct chain_at_index_<chain<Hd, Tl>, i>
00225 {
00226 typedef typename chain_at_index_<Tl, i - 1>::type type;
00227 };
00228
00229
00230 template<class Typelist_Chain, template<typename T> class Transform>
00231 struct chain_transform_;
00232
00233 template<template<typename T> class Transform>
00234 struct chain_transform_<null_type, Transform>
00235 {
00236 typedef null_type type;
00237 };
00238
00239 template<class Hd, class Tl, template<typename T> class Transform>
00240 struct chain_transform_<chain<Hd, Tl>, Transform>
00241 {
00242 typedef typename chain_transform_<Tl, Transform>::type rest_type;
00243 typedef typename Transform<Hd>::type transform_type;
00244 typedef chain<transform_type, rest_type> type;
00245 };
00246
00247
00248 template<typename Typelist_Typelist_Chain>
00249 struct typelist_append_;
00250
00251 template<typename Hd>
00252 struct typelist_append_<chain<Hd, null_type> >
00253 {
00254 typedef chain<Hd, null_type> type;
00255 };
00256
00257 template<typename Hd, typename Tl>
00258 struct typelist_append_<chain< Hd, Tl> >
00259 {
00260 private:
00261 typedef typename typelist_append_<Tl>::type rest;
00262
00263 public:
00264 typedef typename append<Hd, typelist<rest> >::type::root type;
00265 };
00266 }
00267 }
00268
00269
00270 namespace __gnu_cxx
00271 {
00272 template<typename Fn, typename Typelist>
00273 struct apply
00274 {
00275 void
00276 operator()(Fn& f)
00277 {
00278 typedef typename Typelist::root root_type;
00279 detail::apply_<Fn, root_type> a;
00280 a(f);
00281 }
00282 };
00283
00284 template<typename Typelist0, typename Typelist1>
00285 struct append
00286 {
00287 private:
00288 typedef typename Typelist0::root root0_type;
00289 typedef typename Typelist1::root root1_type;
00290 typedef detail::append_<root0_type, root1_type> append_type;
00291
00292 public:
00293 typedef typelist<typename append_type::type> type;
00294 };
00295
00296 template<typename Typelist_Typelist>
00297 struct typelist_append
00298 {
00299 private:
00300 typedef typename Typelist_Typelist::root root_type;
00301 typedef detail::typelist_append_<root_type> append_type;
00302
00303 public:
00304 typedef typelist<typename append_type::type> type;
00305 };
00306
00307 template<typename Typelist, typename T>
00308 struct contains
00309 {
00310 typedef typename Typelist::root root_type;
00311
00312 enum
00313 {
00314 value = detail::contains_<root_type, T>::value
00315 };
00316 };
00317
00318 template<typename Typelist, template<typename T> class Pred>
00319 struct filter
00320 {
00321 private:
00322 typedef typename Typelist::root root_type;
00323 typedef detail::chain_filter_<root_type, Pred> filter_type;
00324
00325 public:
00326 typedef typelist<typename filter_type::type> type;
00327 };
00328
00329 template<typename Typelist, int i>
00330 struct at_index
00331 {
00332 typedef typename Typelist::root root_type;
00333 typedef detail::chain_at_index_<root_type, i> index_type;
00334
00335 typedef typename index_type::type type;
00336 };
00337
00338 template<typename Typelist, template<typename T> class Transform>
00339 struct transform
00340 {
00341 private:
00342 typedef typename Typelist::root root_type;
00343 typedef detail::chain_transform_<root_type, Transform> transform_type;
00344
00345 public:
00346 typedef typelist<typename transform_type::type> type;
00347 };
00348 }
00349
00350
00351 #define _GLIBCXX_TYPELIST_CHAIN1(X0) __gnu_cxx::chain<X0, __gnu_cxx::null_type>
00352 #define _GLIBCXX_TYPELIST_CHAIN2(X0, X1) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN1(X1) >
00353 #define _GLIBCXX_TYPELIST_CHAIN3(X0, X1, X2) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN2(X1, X2) >
00354 #define _GLIBCXX_TYPELIST_CHAIN4(X0, X1, X2, X3) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN3(X1, X2, X3) >
00355 #define _GLIBCXX_TYPELIST_CHAIN5(X0, X1, X2, X3, X4) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN4(X1, X2, X3, X4) >
00356 #define _GLIBCXX_TYPELIST_CHAIN6(X0, X1, X2, X3, X4, X5) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN5(X1, X2, X3, X4, X5) >
00357 #define _GLIBCXX_TYPELIST_CHAIN7(X0, X1, X2, X3, X4, X5, X6) __gnu_cxx::chain<X0, _GLIBCXX_TYPELIST_CHAIN6(X1, X2, X3, X4, X5, X6) >
00358 #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) >
00359 #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) >
00360 #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) >
00361 #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) >
00362 #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) >
00363 #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) >
00364 #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) >
00365 #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) >
00366
00367 #endif
00368