typelist.h

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

Generated on Tue Dec 2 04:35:26 2008 for CHROMA by  doxygen 1.4.7