typelist.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: typelist.h,v 3.1 2009/04/17 02:05:30 bjoo Exp $
00003 /*! @file
00004  * @brief Typelist support
00005  */
00006 
00007 #ifndef __typelist_h__
00008 #define __typelist_h__
00009 
00010 #include "typemanip.h"
00011 
00012 namespace Chroma
00013 {
00014 
00015 ////////////////////////////////////////////////////////////////////////////////
00016 // class EmptyType
00017 // Used as a class type that doesn't hold anything
00018 // Useful as a strawman class
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021     class EmptyType {};
00022 
00023 ////////////////////////////////////////////////////////////////////////////////
00024 // class NullType
00025 // Used as a placeholder for "no type here"
00026 // Useful as an end marker in typelists 
00027 ////////////////////////////////////////////////////////////////////////////////
00028 
00029     class NullType {};
00030 
00031 }  // namespace Chroma
00032 
00033 
00034 ////////////////////////////////////////////////////////////////////////////////
00035 // macros TYPELIST_1, TYPELIST_2, ... TYPELIST_50
00036 // Each takes a number of arguments equal to its numeric suffix
00037 // The arguments are type names. TYPELIST_NN generates a typelist containing 
00038 //     all types passed as arguments, in that order.
00039 // Example: TYPELIST_2(char, int) generates a type containing char and int.
00040 ////////////////////////////////////////////////////////////////////////////////
00041 
00042 #define TYPELIST_1(T1) ::Chroma::Typelist<T1, ::Chroma::NullType>
00043 
00044 #define TYPELIST_2(T1, T2) ::Chroma::Typelist<T1, TYPELIST_1(T2) >
00045 
00046 #define TYPELIST_3(T1, T2, T3) ::Chroma::Typelist<T1, TYPELIST_2(T2, T3) >
00047 
00048 #define TYPELIST_4(T1, T2, T3, T4) ::Chroma::Typelist<T1, TYPELIST_3(T2, T3, T4) >
00049 
00050 #define TYPELIST_5(T1, T2, T3, T4, T5) \
00051     ::Chroma::Typelist<T1, TYPELIST_4(T2, T3, T4, T5) >
00052 
00053 #define TYPELIST_6(T1, T2, T3, T4, T5, T6) \
00054     ::Chroma::Typelist<T1, TYPELIST_5(T2, T3, T4, T5, T6) >
00055 
00056 #define TYPELIST_7(T1, T2, T3, T4, T5, T6, T7) \
00057     ::Chroma::Typelist<T1, TYPELIST_6(T2, T3, T4, T5, T6, T7) >
00058 
00059 #define TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8) \
00060     ::Chroma::Typelist<T1, TYPELIST_7(T2, T3, T4, T5, T6, T7, T8) >
00061 
00062 #define TYPELIST_9(T1, T2, T3, T4, T5, T6, T7, T8, T9) \
00063     ::Chroma::Typelist<T1, TYPELIST_8(T2, T3, T4, T5, T6, T7, T8, T9) >
00064 
00065 #define TYPELIST_10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \
00066     ::Chroma::Typelist<T1, TYPELIST_9(T2, T3, T4, T5, T6, T7, T8, T9, T10) >
00067 
00068 #define TYPELIST_11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
00069     ::Chroma::Typelist<T1, TYPELIST_10(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) >
00070 
00071 #define TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \
00072     ::Chroma::Typelist<T1, TYPELIST_11(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00073         T11, T12) >
00074 
00075 #define TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \
00076     ::Chroma::Typelist<T1, TYPELIST_12(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00077         T11, T12, T13) >
00078 
00079 #define TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00080         T11, T12, T13, T14) \
00081     ::Chroma::Typelist<T1, TYPELIST_13(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00082         T11, T12, T13, T14) >
00083 
00084 #define TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00085         T11, T12, T13, T14, T15) \
00086     ::Chroma::Typelist<T1, TYPELIST_14(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00087         T11, T12, T13, T14, T15) >
00088 
00089 #define TYPELIST_16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00090         T11, T12, T13, T14, T15, T16) \
00091     ::Chroma::Typelist<T1, TYPELIST_15(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00092         T11, T12, T13, T14, T15, T16) >
00093 
00094 #define TYPELIST_17(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00095         T11, T12, T13, T14, T15, T16, T17) \
00096     ::Chroma::Typelist<T1, TYPELIST_16(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00097         T11, T12, T13, T14, T15, T16, T17) >
00098 
00099 #define TYPELIST_18(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00100         T11, T12, T13, T14, T15, T16, T17, T18) \
00101     ::Chroma::Typelist<T1, TYPELIST_17(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00102         T11, T12, T13, T14, T15, T16, T17, T18) >
00103 
00104 #define TYPELIST_19(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00105         T11, T12, T13, T14, T15, T16, T17, T18, T19) \
00106     ::Chroma::Typelist<T1, TYPELIST_18(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00107         T11, T12, T13, T14, T15, T16, T17, T18, T19) >
00108 
00109 #define TYPELIST_20(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00110         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) \
00111     ::Chroma::Typelist<T1, TYPELIST_19(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00112         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) >
00113 
00114 #define TYPELIST_21(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00115         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) \
00116     ::Chroma::Typelist<T1, TYPELIST_20(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00117         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) >
00118 
00119 #define TYPELIST_22(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00120         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) \
00121     ::Chroma::Typelist<T1, TYPELIST_21(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00122         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) >
00123 
00124 #define TYPELIST_23(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00125         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) \
00126     ::Chroma::Typelist<T1, TYPELIST_22(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00127         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) >
00128 
00129 #define TYPELIST_24(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00130         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) \
00131     ::Chroma::Typelist<T1, TYPELIST_23(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00132         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) >
00133 
00134 #define TYPELIST_25(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00135         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25) \
00136     ::Chroma::Typelist<T1, TYPELIST_24(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00137         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00138         T21, T22, T23, T24, T25) >
00139 
00140 #define TYPELIST_26(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00141         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00142         T21, T22, T23, T24, T25, T26) \
00143     ::Chroma::Typelist<T1, TYPELIST_25(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00144         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00145         T21, T22, T23, T24, T25, T26) >
00146 
00147 #define TYPELIST_27(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00148         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00149         T21, T22, T23, T24, T25, T26, T27) \
00150     ::Chroma::Typelist<T1, TYPELIST_26(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00151         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00152         T21, T22, T23, T24, T25, T26, T27) >
00153 
00154 #define TYPELIST_28(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00155         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00156         T21, T22, T23, T24, T25, T26, T27, T28) \
00157     ::Chroma::Typelist<T1, TYPELIST_27(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00158         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00159         T21, T22, T23, T24, T25, T26, T27, T28) >
00160 
00161 #define TYPELIST_29(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00162         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00163         T21, T22, T23, T24, T25, T26, T27, T28, T29) \
00164     ::Chroma::Typelist<T1, TYPELIST_28(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00165         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00166         T21, T22, T23, T24, T25, T26, T27, T28, T29) >
00167 
00168 #define TYPELIST_30(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00169         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00170         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) \
00171     ::Chroma::Typelist<T1, TYPELIST_29(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00172         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00173         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) >
00174 
00175 #define TYPELIST_31(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00176         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00177         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) \
00178     ::Chroma::Typelist<T1, TYPELIST_30(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00179         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00180         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) >
00181 
00182 #define TYPELIST_32(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00183         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00184         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) \
00185     ::Chroma::Typelist<T1, TYPELIST_31(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00186         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00187         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) >
00188 
00189 #define TYPELIST_33(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00190         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00191         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) \
00192     ::Chroma::Typelist<T1, TYPELIST_32(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00193         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00194         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) >
00195 
00196 #define TYPELIST_34(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00197         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00198         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) \
00199     ::Chroma::Typelist<T1, TYPELIST_33(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00200         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00201         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) >
00202 
00203 #define TYPELIST_35(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00204         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00205         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00206         T31, T32, T33, T34, T35) \
00207     ::Chroma::Typelist<T1, TYPELIST_34(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00208         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00209         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00210         T31, T32, T33, T34, T35) >
00211 
00212 #define TYPELIST_36(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00213         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00214         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00215         T31, T32, T33, T34, T35, T36) \
00216     ::Chroma::Typelist<T1, TYPELIST_35(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00217         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00218         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00219         T31, T32, T33, T34, T35, T36) >
00220 
00221 #define TYPELIST_37(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00222         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00223         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00224         T31, T32, T33, T34, T35, T36, T37) \
00225     ::Chroma::Typelist<T1, TYPELIST_36(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00226         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00227         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00228         T31, T32, T33, T34, T35, T36, T37) >
00229 
00230 #define TYPELIST_38(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00231         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00232         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00233         T31, T32, T33, T34, T35, T36, T37, T38) \
00234     ::Chroma::Typelist<T1, TYPELIST_37(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00235         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00236         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00237         T31, T32, T33, T34, T35, T36, T37, T38) >
00238 
00239 #define TYPELIST_39(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00240         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00241         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00242         T31, T32, T33, T34, T35, T36, T37, T38, T39) \
00243     ::Chroma::Typelist<T1, TYPELIST_38(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00244         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00245         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00246         T31, T32, T33, T34, T35, T36, T37, T38, T39) >
00247 
00248 #define TYPELIST_40(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00249         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00250         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00251         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) \
00252     ::Chroma::Typelist<T1, TYPELIST_39(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00253         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00254         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00255         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) >
00256 
00257 #define TYPELIST_41(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00258         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00259         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00260         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) \
00261     ::Chroma::Typelist<T1, TYPELIST_40(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00262         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00263         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00264         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) >
00265 
00266 #define TYPELIST_42(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00267         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00268         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00269         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) \
00270     ::Chroma::Typelist<T1, TYPELIST_41(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00271         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00272         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00273         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) >
00274 
00275 #define TYPELIST_43(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00276         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00277         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00278         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) \
00279     ::Chroma::Typelist<T1, TYPELIST_42(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00280         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00281         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00282         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) >
00283 
00284 #define TYPELIST_44(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00285         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00286         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00287         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) \
00288     ::Chroma::Typelist<T1, TYPELIST_43(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00289         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00290         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00291         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) >
00292 
00293 #define TYPELIST_45(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00294         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00295         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00296         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00297         T41, T42, T43, T44, T45) \
00298     ::Chroma::Typelist<T1, TYPELIST_44(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00299         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00300         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00301         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00302         T41, T42, T43, T44, T45) >
00303 
00304 #define TYPELIST_46(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00305         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00306         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00307         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00308         T41, T42, T43, T44, T45, T46) \
00309     ::Chroma::Typelist<T1, TYPELIST_45(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00310         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00311         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00312         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00313         T41, T42, T43, T44, T45) >
00314 
00315 #define TYPELIST_47(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00316         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00317         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00318         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00319         T41, T42, T43, T44, T45, T46, T47) \
00320     ::Chroma::Typelist<T1, TYPELIST_46(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00321         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00322         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00323         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00324         T41, T42, T43, T44, T45, T46, T47) >
00325 
00326 #define TYPELIST_48(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00327         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00328         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00329         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00330         T41, T42, T43, T44, T45, T46, T47, T48) \
00331     ::Chroma::Typelist<T1, TYPELIST_47(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00332         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00333         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00334         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00335         T41, T42, T43, T44, T45, T46, T47, T48) >
00336 
00337 #define TYPELIST_49(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00338         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00339         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00340         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00341         T41, T42, T43, T44, T45, T46, T47, T48, T49) \
00342     ::Chroma::Typelist<T1, TYPELIST_48(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00343         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00344         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00345         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00346         T41, T42, T43, T44, T45, T46, T47, T48, T49) >
00347 
00348 #define TYPELIST_50(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00349         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00350         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00351         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00352         T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) \
00353     ::Chroma::Typelist<T1, TYPELIST_49(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
00354         T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
00355         T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
00356         T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
00357         T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) >
00358 
00359 namespace Chroma
00360 {
00361 ////////////////////////////////////////////////////////////////////////////////
00362 // class template Typelist
00363 // The building block of typelists of any length
00364 // Use it through the TYPELIST_NN macros
00365 // Defines nested types:
00366 //     Head (first element, a non-typelist type by convention)
00367 //     Tail (second element, can be another typelist)
00368 ////////////////////////////////////////////////////////////////////////////////
00369 
00370   template <class T, class U>
00371   struct Typelist
00372   {
00373     typedef T Head;
00374     typedef U Tail;
00375   };
00376 
00377   namespace TL
00378   {
00379 ////////////////////////////////////////////////////////////////////////////////
00380 // class template Length
00381 // Computes the length of a typelist
00382 // Invocation (TList is a typelist):
00383 // Length<TList>::value
00384 // returns a compile-time constant containing the length of TList, not counting
00385 //     the end terminator (which by convention is NullType)
00386 ////////////////////////////////////////////////////////////////////////////////
00387 
00388     template <class TList> struct Length;
00389     template <> struct Length<NullType>
00390     {
00391       enum { value = 0 };
00392     };
00393         
00394     template <class T, class U>
00395     struct Length< Typelist<T, U> >
00396     {
00397       enum { value = 1 + Length<U>::value };
00398     };
00399 
00400 ////////////////////////////////////////////////////////////////////////////////
00401 // class template TypeAt
00402 // Finds the type at a given index in a typelist
00403 // Invocation (TList is a typelist and index is a compile-time integral 
00404 //     constant):
00405 // TypeAt<TList, index>::Result
00406 // returns the type in position 'index' in TList
00407 // If you pass an out-of-bounds index, the result is a compile-time error
00408 ////////////////////////////////////////////////////////////////////////////////
00409 
00410     template <class TList, int index> struct TypeAt;
00411         
00412     template <class Head, class Tail>
00413     struct TypeAt<Typelist<Head, Tail>, 0>
00414     {
00415       typedef Head Result;
00416     };
00417 
00418     template <class Head, class Tail, int i>
00419     struct TypeAt<Typelist<Head, Tail>, i>
00420     {
00421       typedef typename TypeAt<Tail, i - 1>::Result Result;
00422     };
00423 
00424 ////////////////////////////////////////////////////////////////////////////////
00425 // class template TypeAtNonStrict
00426 // Finds the type at a given index in a typelist
00427 // Invocations (TList is a typelist and index is a compile-time integral 
00428 //     constant):
00429 // a) TypeAt<TList, index>::Result
00430 // returns the type in position 'index' in TList, or NullType if index is 
00431 //     out-of-bounds
00432 // b) TypeAt<TList, index, D>::Result
00433 // returns the type in position 'index' in TList, or D if index is out-of-bounds
00434 ////////////////////////////////////////////////////////////////////////////////
00435 
00436     template <class TList, int index,
00437       typename DefaultType = NullType>
00438     struct TypeAtNonStrict
00439     {
00440       typedef DefaultType Result;
00441     };
00442         
00443     template <class Head, class Tail, typename DefaultType>
00444     struct TypeAtNonStrict<Typelist<Head, Tail>, 0, DefaultType>
00445     {
00446       typedef Head Result;
00447     };
00448         
00449     template <class Head, class Tail, int i, typename DefaultType>
00450     struct TypeAtNonStrict<Typelist<Head, Tail>, i, DefaultType>
00451     {
00452       typedef typename 
00453       TypeAtNonStrict<Tail, i - 1, DefaultType>::Result Result;
00454     };
00455 
00456 ////////////////////////////////////////////////////////////////////////////////
00457 // class template IndexOf
00458 // Finds the index of a type in a typelist
00459 // Invocation (TList is a typelist and T is a type):
00460 // IndexOf<TList, T>::value
00461 // returns the position of T in TList, or NullType if T is not found in TList
00462 ////////////////////////////////////////////////////////////////////////////////
00463 
00464     template <class TList, class T> struct IndexOf;
00465         
00466     template <class T>
00467     struct IndexOf<NullType, T>
00468     {
00469       enum { value = -1 };
00470     };
00471         
00472     template <class T, class Tail>
00473     struct IndexOf<Typelist<T, Tail>, T>
00474     {
00475       enum { value = 0 };
00476     };
00477         
00478     template <class Head, class Tail, class T>
00479     struct IndexOf<Typelist<Head, Tail>, T>
00480     {
00481     private:
00482       enum { temp = IndexOf<Tail, T>::value };
00483     public:
00484       enum { value = (temp == -1 ? -1 : 1 + temp) };
00485     };
00486 
00487 ////////////////////////////////////////////////////////////////////////////////
00488 // class template Append
00489 // Appends a type or a typelist to another
00490 // Invocation (TList is a typelist and T is either a type or a typelist):
00491 // Append<TList, T>::Result
00492 // returns a typelist that is TList followed by T and NullType-terminated
00493 ////////////////////////////////////////////////////////////////////////////////
00494 
00495     template <class TList, class T> struct Append;
00496         
00497     template <> struct Append<NullType, NullType>
00498     {
00499       typedef NullType Result;
00500     };
00501         
00502     template <class T> struct Append<NullType, T>
00503     {
00504       typedef TYPELIST_1(T) Result;
00505     };
00506         
00507     template <class Head, class Tail>
00508     struct Append<NullType, Typelist<Head, Tail> >
00509     {
00510       typedef Typelist<Head, Tail> Result;
00511     };
00512         
00513     template <class Head, class Tail, class T>
00514     struct Append<Typelist<Head, Tail>, T>
00515     {
00516       typedef Typelist<Head, 
00517         typename Append<Tail, T>::Result>
00518       Result;
00519     };
00520         
00521 ////////////////////////////////////////////////////////////////////////////////
00522 // class template Erase
00523 // Erases the first occurence, if any, of a type in a typelist
00524 // Invocation (TList is a typelist and T is a type):
00525 // Erase<TList, T>::Result
00526 // returns a typelist that is TList without the first occurence of T
00527 ////////////////////////////////////////////////////////////////////////////////
00528 
00529     template <class TList, class T> struct Erase;
00530         
00531     template <class T>                         // Specialization 1
00532     struct Erase<NullType, T>
00533     {
00534       typedef NullType Result;
00535     };
00536 
00537     template <class T, class Tail>             // Specialization 2
00538     struct Erase<Typelist<T, Tail>, T>
00539     {
00540       typedef Tail Result;
00541     };
00542 
00543     template <class Head, class Tail, class T> // Specialization 3
00544     struct Erase<Typelist<Head, Tail>, T>
00545     {
00546       typedef Typelist<Head, 
00547         typename Erase<Tail, T>::Result>
00548       Result;
00549     };
00550 
00551 ////////////////////////////////////////////////////////////////////////////////
00552 // class template EraseAll
00553 // Erases all first occurences, if any, of a type in a typelist
00554 // Invocation (TList is a typelist and T is a type):
00555 // EraseAll<TList, T>::Result
00556 // returns a typelist that is TList without any occurence of T
00557 ////////////////////////////////////////////////////////////////////////////////
00558 
00559     template <class TList, class T> struct EraseAll;
00560     template <class T>
00561     struct EraseAll<NullType, T>
00562     {
00563       typedef NullType Result;
00564     };
00565     template <class T, class Tail>
00566     struct EraseAll<Typelist<T, Tail>, T>
00567     {
00568       // Go all the way down the list removing the type
00569       typedef typename EraseAll<Tail, T>::Result Result;
00570     };
00571     template <class Head, class Tail, class T>
00572     struct EraseAll<Typelist<Head, Tail>, T>
00573     {
00574       // Go all the way down the list removing the type
00575       typedef Typelist<Head, 
00576         typename EraseAll<Tail, T>::Result>
00577       Result;
00578     };
00579 
00580 ////////////////////////////////////////////////////////////////////////////////
00581 // class template NoDuplicates
00582 // Removes all duplicate types in a typelist
00583 // Invocation (TList is a typelist):
00584 // NoDuplicates<TList, T>::Result
00585 ////////////////////////////////////////////////////////////////////////////////
00586 
00587     template <class TList> struct NoDuplicates;
00588         
00589     template <> struct NoDuplicates<NullType>
00590     {
00591       typedef NullType Result;
00592     };
00593 
00594     template <class Head, class Tail>
00595     struct NoDuplicates< Typelist<Head, Tail> >
00596     {
00597     private:
00598       typedef typename NoDuplicates<Tail>::Result L1;
00599       typedef typename Erase<L1, Head>::Result L2;
00600     public:
00601       typedef Typelist<Head, L2> Result;
00602     };
00603 
00604 ////////////////////////////////////////////////////////////////////////////////
00605 // class template Replace
00606 // Replaces the first occurence of a type in a typelist, with another type
00607 // Invocation (TList is a typelist, T, U are types):
00608 // Replace<TList, T, U>::Result
00609 // returns a typelist in which the first occurence of T is replaced with U
00610 ////////////////////////////////////////////////////////////////////////////////
00611 
00612     template <class TList, class T, class U> struct Replace;
00613         
00614     template <class T, class U>
00615     struct Replace<NullType, T, U>
00616     {
00617       typedef NullType Result;
00618     };
00619 
00620     template <class T, class Tail, class U>
00621     struct Replace<Typelist<T, Tail>, T, U>
00622     {
00623       typedef Typelist<U, Tail> Result;
00624     };
00625 
00626     template <class Head, class Tail, class T, class U>
00627     struct Replace<Typelist<Head, Tail>, T, U>
00628     {
00629       typedef Typelist<Head,
00630         typename Replace<Tail, T, U>::Result>
00631       Result;
00632     };
00633 
00634 ////////////////////////////////////////////////////////////////////////////////
00635 // class template ReplaceAll
00636 // Replaces all occurences of a type in a typelist, with another type
00637 // Invocation (TList is a typelist, T, U are types):
00638 // Replace<TList, T, U>::Result
00639 // returns a typelist in which all occurences of T is replaced with U
00640 ////////////////////////////////////////////////////////////////////////////////
00641 
00642     template <class TList, class T, class U> struct ReplaceAll;
00643         
00644     template <class T, class U>
00645     struct ReplaceAll<NullType, T, U>
00646     {
00647       typedef NullType Result;
00648     };
00649         
00650     template <class T, class Tail, class U>
00651     struct ReplaceAll<Typelist<T, Tail>, T, U>
00652     {
00653       typedef Typelist<U, typename ReplaceAll<Tail, T, U>::Result> Result;
00654     };
00655         
00656     template <class Head, class Tail, class T, class U>
00657     struct ReplaceAll<Typelist<Head, Tail>, T, U>
00658     {
00659       typedef Typelist<Head,
00660         typename ReplaceAll<Tail, T, U>::Result>
00661       Result;
00662     };
00663 
00664 ////////////////////////////////////////////////////////////////////////////////
00665 // class template Reverse
00666 // Reverses a typelist
00667 // Invocation (TList is a typelist):
00668 // Reverse<TList>::Result
00669 // returns a typelist that is TList reversed
00670 ////////////////////////////////////////////////////////////////////////////////
00671 
00672     template <class TList> struct Reverse;
00673         
00674     template <class T>
00675     struct Reverse< TYPELIST_1(T) >
00676     {
00677       typedef TYPELIST_1(T) Result;
00678     };
00679         
00680     template <class Head, class Tail>
00681     struct Reverse< Typelist<Head, Tail> >
00682     {
00683       typedef typename Append<
00684       typename Reverse<Tail>::Result, Head>::Result Result;
00685     };
00686 
00687 ////////////////////////////////////////////////////////////////////////////////
00688 // class template MostDerived
00689 // Finds the type in a typelist that is the most derived from a given type
00690 // Invocation (TList is a typelist, T is a type):
00691 // Replace<TList, T>::Result
00692 // returns the type in TList that's the most derived from T
00693 ////////////////////////////////////////////////////////////////////////////////
00694 
00695     template <class TList, class T> struct MostDerived;
00696         
00697     template <class T>
00698     struct MostDerived<NullType, T>
00699     {
00700       typedef T Result;
00701     };
00702         
00703     template <class Head, class Tail, class T>
00704     struct MostDerived<Typelist<Head, Tail>, T>
00705     {
00706     private:
00707       typedef typename MostDerived<Tail, T>::Result Candidate;
00708     public:
00709       typedef typename Select<
00710       SUPERSUBCLASS(Candidate, Head),
00711         Head, Candidate>::Result Result;
00712     };
00713 
00714 ////////////////////////////////////////////////////////////////////////////////
00715 // class template DerivedToFront
00716 // Arranges the types in a typelist so that the most derived types appear first
00717 // Invocation (TList is a typelist):
00718 // DerivedToFront<TList>::Result
00719 // returns the reordered TList 
00720 ////////////////////////////////////////////////////////////////////////////////
00721 
00722     template <class TList> struct DerivedToFront;
00723         
00724     template <>
00725     struct DerivedToFront<NullType>
00726     {
00727       typedef NullType Result;
00728     };
00729         
00730     template <class Head, class Tail>
00731     struct DerivedToFront< Typelist<Head, Tail> >
00732     {
00733     private:
00734       typedef typename MostDerived<Tail, Head>::Result
00735       TheMostDerived;
00736       typedef typename Replace<Tail, 
00737         TheMostDerived, Head>::Result L;
00738     public:
00739       typedef Typelist<TheMostDerived, L> Result;
00740     };
00741         
00742   }   // namespace TL
00743 }   // namespace Chroma
00744 
00745 #endif

Generated on Sun Nov 22 04:37:56 2009 for CHROMA by  doxygen 1.4.7