00001
00002
00003
00004
00005
00006
00007
00008
00013 #ifndef meta_switch_h
00014 #define meta_switch_h
00015
00016 #include <cml/core/meta/common.h>
00017 #include <cml/core/meta/if.h>
00018
00019 namespace cml {
00020
00021 struct NilCase {};
00022 struct Default {};
00023
00024
00025 namespace meta {
00026
00027
00028 template<typename Case, typename Result, typename NextCase>
00029 struct select_case
00030 {
00031 template<typename Find> struct match {
00032 typedef typename select_if<
00033 same_type<Find,Case>::is_true,
00034 Result,
00035 typename NextCase::template match<Find>::result
00036 >::result result;
00037 };
00038 };
00039
00040
00041 template<typename Result>
00042 struct select_case<Default,Result,NilCase>
00043 {
00044 template<typename Find> struct match {
00045 typedef Result result;
00046 };
00047 };
00048
00049
00050 template<typename Case, typename Result>
00051 struct select_case<Case,Result,NilCase>
00052 {
00053 template<typename Find> struct match {
00054 typedef typename select_if<
00055 same_type<Find,Case>::is_true,
00056 Result,
00057 void
00058 >::result result;
00059 };
00060 };
00061
00062 }
00063
00069 template<typename Find
00070 , typename T1, typename R1
00071 , typename T2 = NilCase, typename R2 = void
00072 , typename T3 = NilCase, typename R3 = void
00073 , typename T4 = NilCase, typename R4 = void
00074 , typename T5 = NilCase, typename R5 = void
00075 , typename T6 = NilCase, typename R6 = void
00076 , typename T7 = NilCase, typename R7 = void
00077 , typename T8 = NilCase, typename R8 = void
00078 , typename T9 = NilCase, typename R9 = void
00079 , typename T10 = NilCase, typename R10 = void
00080 , typename T11 = NilCase, typename R11 = void
00081 , typename T12 = NilCase, typename R12 = void
00082 , typename T13 = NilCase, typename R13 = void
00083 , typename T14 = NilCase, typename R14 = void
00084 , typename T15 = NilCase, typename R15 = void
00085 , typename T16 = NilCase, typename R16 = void
00086 #if !defined(_MSC_VER)
00087 , typename T17 = NilCase, typename R17 = void
00088 , typename T18 = NilCase, typename R18 = void
00089 , typename T19 = NilCase, typename R19 = void
00090 , typename T20 = NilCase, typename R20 = void
00091 , typename T21 = NilCase, typename R21 = void
00092 , typename T22 = NilCase, typename R22 = void
00093 , typename T23 = NilCase, typename R23 = void
00094 , typename T24 = NilCase, typename R24 = void
00095 , typename T25 = NilCase, typename R25 = void
00096 , typename T26 = NilCase, typename R26 = void
00097 , typename T27 = NilCase, typename R27 = void
00098 , typename T28 = NilCase, typename R28 = void
00099 , typename T29 = NilCase, typename R29 = void
00100 , typename T30 = NilCase, typename R30 = void
00101 , typename T31 = NilCase, typename R31 = void
00102 , typename T32 = NilCase, typename R32 = void
00103 , typename T33 = NilCase, typename R33 = void
00104 , typename T34 = NilCase, typename R34 = void
00105 , typename T35 = NilCase, typename R35 = void
00106 , typename T36 = NilCase, typename R36 = void
00107 , typename T37 = NilCase, typename R37 = void
00108 , typename T38 = NilCase, typename R38 = void
00109 , typename T39 = NilCase, typename R39 = void
00110 , typename T40 = NilCase, typename R40 = void
00111 #endif
00112 > struct select_switch
00113 {
00114 typedef typename
00115 meta::select_case< T1,R1
00116 , meta::select_case< T2,R2
00117 , meta::select_case< T3,R3
00118 , meta::select_case< T4,R4
00119 , meta::select_case< T5,R5
00120 , meta::select_case< T6,R6
00121 , meta::select_case< T7,R7
00122 , meta::select_case< T8,R8
00123 , meta::select_case< T9,R9
00124 , meta::select_case< T10,R10
00125 , meta::select_case< T11,R11
00126 , meta::select_case< T12,R12
00127 , meta::select_case< T13,R13
00128 , meta::select_case< T14,R14
00129 , meta::select_case< T15,R15
00130 , meta::select_case< T16,R16
00131 #if !defined(_MSC_VER)
00132 , meta::select_case< T17,R17
00133 , meta::select_case< T18,R18
00134 , meta::select_case< T19,R19
00135 , meta::select_case< T20,R20
00136 , meta::select_case< T21,R21
00137 , meta::select_case< T22,R22
00138 , meta::select_case< T23,R23
00139 , meta::select_case< T24,R24
00140 , meta::select_case< T25,R25
00141 , meta::select_case< T26,R26
00142 , meta::select_case< T27,R27
00143 , meta::select_case< T28,R28
00144 , meta::select_case< T29,R29
00145 , meta::select_case< T30,R30
00146 , meta::select_case< T31,R31
00147 , meta::select_case< T32,R32
00148 , meta::select_case< T33,R33
00149 , meta::select_case< T34,R34
00150 , meta::select_case< T35,R35
00151 , meta::select_case< T36,R36
00152 , meta::select_case< T37,R37
00153 , meta::select_case< T38,R38
00154 , meta::select_case< T39,R39
00155 , meta::select_case< T40,R40
00156 , NilCase
00157 > > > > > > > > > >
00158 > > > > > > > > > >
00159 > > > >
00160 #else
00161 , NilCase
00162 #endif
00163 > > > > > >
00164 > > > > > > > > > >
00165 ::template match<Find>::result result;
00166 };
00167
00168 }
00169
00170 #endif
00171
00172
00173