00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00020 #ifndef _ARAGELI_mixcomp_hpp_
00021 #define _ARAGELI_mixcomp_hpp_
00022
00023 #include "config.hpp"
00024
00025 #include "basefuncs.hpp"
00026
00027
00028
00029
00030
00031 namespace Arageli
00032 {
00033
00034
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00047
00052 template <typename Tag, typename Owner, typename T1, typename T2>
00053 struct binary_function_gate_slot
00054 {
00055
00056
00057
00058 };
00059
00060
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00088
00099 #define ARAGELI_BINARY_FUNCTION_MIXGATE(FUNC, OPER) \
00100 template \
00101 < \
00102 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_PARAMS \
00103 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OTHER_COMMA \
00104 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_PARAMS \
00105 > \
00106 struct binary_function_traits \
00107 < \
00108 function_tag::FUNC, \
00109 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00110 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE \
00111 > : \
00112 public binary_function_gate_slot \
00113 < \
00114 function_tag::FUNC, \
00115 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00116 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00117 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE \
00118 >::function_traits \
00119 {}; \
00120 \
00121 template \
00122 < \
00123 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_PARAMS \
00124 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OTHER_COMMA \
00125 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_PARAMS \
00126 > \
00127 struct binary_function_traits \
00128 < \
00129 function_tag::FUNC, \
00130 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE, \
00131 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE \
00132 > : \
00133 public binary_function_gate_slot \
00134 < \
00135 function_tag::FUNC, \
00136 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE, \
00137 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE, \
00138 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE \
00139 >::function_traits \
00140 {}; \
00141 \
00142 template \
00143 < \
00144 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_PARAMS \
00145 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OTHER_COMMA \
00146 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_PARAMS \
00147 > \
00148 inline typename binary_function_traits \
00149 < \
00150 function_tag::FUNC, \
00151 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00152 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE \
00153 >::result_type \
00154 OPER \
00155 ( \
00156 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE a, \
00157 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE b \
00158 ) \
00159 { \
00160 return binary_function_gate_slot \
00161 < \
00162 function_tag::FUNC, \
00163 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00164 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00165 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE \
00166 >::function(a, b); \
00167 } \
00168 \
00169 template \
00170 < \
00171 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_PARAMS \
00172 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OTHER_COMMA \
00173 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_PARAMS \
00174 > \
00175 inline typename binary_function_traits \
00176 < \
00177 function_tag::FUNC, \
00178 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE, \
00179 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE \
00180 >::result_type \
00181 OPER \
00182 ( \
00183 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE a, \
00184 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE b \
00185 ) \
00186 { \
00187 return binary_function_gate_slot \
00188 < \
00189 function_tag::FUNC, \
00190 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE, \
00191 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE, \
00192 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE \
00193 >::function(a, b); \
00194 }
00195
00196
00197 #define ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(FUNC, OPER) \
00198 template \
00199 < \
00200 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_PARAMS \
00201 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OWNER_COMMA \
00202 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_PARAMS \
00203 > \
00204 struct binary_function_traits \
00205 < \
00206 function_tag::FUNC, \
00207 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00208 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE \
00209 > : \
00210 public binary_function_gate_slot \
00211 < \
00212 function_tag::FUNC, \
00213 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00214 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00215 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE \
00216 >::function_traits \
00217 {}; \
00218 \
00219 template \
00220 < \
00221 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_PARAMS \
00222 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OWNER_COMMA \
00223 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_PARAMS \
00224 > \
00225 inline typename binary_function_traits \
00226 < \
00227 function_tag::FUNC, \
00228 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00229 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE \
00230 >::result_type \
00231 OPER \
00232 ( \
00233 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE a, \
00234 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE b \
00235 ) \
00236 { \
00237 return binary_function_gate_slot \
00238 < \
00239 function_tag::FUNC, \
00240 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00241 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE, \
00242 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE \
00243 >::function(a, b); \
00244 }
00245
00246
00247 #define ARAGELI_BINARY_COMPARISON_MIXGATE(FUNC, OPER, OP) \
00248 template \
00249 < \
00250 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_PARAMS \
00251 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OTHER_COMMA \
00252 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_PARAMS \
00253 > \
00254 inline bool OPER \
00255 ( \
00256 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE a, \
00257 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE b \
00258 ) \
00259 { return (cmp(a, b) OP 0); } \
00260 \
00261 template \
00262 < \
00263 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_PARAMS \
00264 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OTHER_COMMA \
00265 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_PARAMS \
00266 > \
00267 inline bool OPER \
00268 ( \
00269 ARAGELI_BINARY_FUNCTION_MIXGATE_OTHER_TYPE a, \
00270 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE b \
00271 ) \
00272 { return (cmp(a, b) OP 0); }
00273
00274
00275 #define ARAGELI_BINARY_COMPARISON_SELF_MIXGATE(FUNC, OPER, OP) \
00276 template \
00277 < \
00278 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_PARAMS \
00279 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_OWNER_COMMA \
00280 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_PARAMS \
00281 > \
00282 inline bool OPER \
00283 ( \
00284 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_1_TYPE a, \
00285 ARAGELI_BINARY_FUNCTION_MIXGATE_OWNER_2_TYPE b \
00286 ) \
00287 { return (cmp(a, b) OP 0); }
00288
00289
00290 #define ARAGELI_ALL_BINARY_ARITHM_FUNCTIONS_MIXGATE \
00291 ARAGELI_BINARY_FUNCTION_MIXGATE(plus, operator+) \
00292 ARAGELI_BINARY_FUNCTION_MIXGATE(minus, operator-) \
00293 ARAGELI_BINARY_FUNCTION_MIXGATE(multiplies, operator*) \
00294 ARAGELI_BINARY_FUNCTION_MIXGATE(divides, operator/) \
00295 ARAGELI_BINARY_FUNCTION_MIXGATE(modulus, operator%) \
00296 ARAGELI_BINARY_FUNCTION_MIXGATE(bitwise_or, operator|) \
00297 ARAGELI_BINARY_FUNCTION_MIXGATE(bitwise_and, operator&) \
00298 ARAGELI_BINARY_FUNCTION_MIXGATE(bitwise_xor, operator^) \
00299 ARAGELI_BINARY_FUNCTION_MIXGATE(shift_left, operator<<) \
00300 ARAGELI_BINARY_FUNCTION_MIXGATE(shift_right, operator>>)
00301
00302 #define ARAGELI_ALL_BINARY_LOGIC_FUNCTIONS_MIXGATE \
00303 ARAGELI_BINARY_FUNCTION_MIXGATE(logical_or, operator||) \
00304 ARAGELI_BINARY_FUNCTION_MIXGATE(logical_and, operator&&)
00305
00306 #define ARAGELI_ALL_BINARY_CMP_MIXGATE \
00307 ARAGELI_BINARY_FUNCTION_MIXGATE(cmp, cmp) \
00308 ARAGELI_BINARY_COMPARISON_MIXGATE(equal_to, operator==, ==) \
00309 ARAGELI_BINARY_COMPARISON_MIXGATE(not_equal_to, operator!=, !=) \
00310 ARAGELI_BINARY_COMPARISON_MIXGATE(greater, operator>, >) \
00311 ARAGELI_BINARY_COMPARISON_MIXGATE(less, operator<, <) \
00312 ARAGELI_BINARY_COMPARISON_MIXGATE(greater_equal, operator>=, >=)\
00313 ARAGELI_BINARY_COMPARISON_MIXGATE(less_equal, operator<=, <=)
00314
00315 #define ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(NAME) \
00316 ARAGELI_BINARY_FUNCTION_MIXGATE(NAME, NAME)
00317
00318 #define ARAGELI_ALL_EACH_ALL_CMP_FUNCTIONS_MIXGATE \
00319 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(each_equal_to) \
00320 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(each_not_equal_to) \
00321 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(each_greater) \
00322 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(each_less) \
00323 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(each_greater_equal) \
00324 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(each_less_equal) \
00325 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(all_equal_to) \
00326 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(all_not_equal_to) \
00327 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(all_greater) \
00328 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(all_less) \
00329 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(all_greater_equal) \
00330 ARAGELI_BINARY_FUNCTION_MIXGATE_SAMENAME(all_less_equal)
00331
00332 #define ARAGELI_ALL_BINARY_ARITHM_FUNCTIONS_SELF_MIXGATE \
00333 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(plus, operator+) \
00334 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(minus, operator-) \
00335 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(multiplies, operator*) \
00336 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(divides, operator/) \
00337 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(modulus, operator%) \
00338 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(bitwise_or, operator|) \
00339 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(bitwise_and, operator&) \
00340 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(bitwise_xor, operator^) \
00341 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(shift_left, operator<<) \
00342 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(shift_right, operator>>)
00343
00344 #define ARAGELI_ALL_BINARY_LOGIC_FUNCTIONS_SELF_MIXGATE \
00345 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(logical_or, operator||) \
00346 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(logical_and, operator&&)
00347
00348 #define ARAGELI_ALL_BINARY_CMP_SELF_MIXGATE \
00349 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(cmp, cmp) \
00350 ARAGELI_BINARY_COMPARISON_SELF_MIXGATE(equal_to, operator==, ==) \
00351 ARAGELI_BINARY_COMPARISON_SELF_MIXGATE(not_equal_to, operator!=, !=) \
00352 ARAGELI_BINARY_COMPARISON_SELF_MIXGATE(greater, operator>, >) \
00353 ARAGELI_BINARY_COMPARISON_SELF_MIXGATE(less, operator<, <) \
00354 ARAGELI_BINARY_COMPARISON_SELF_MIXGATE(greater_equal, operator>=, >=) \
00355 ARAGELI_BINARY_COMPARISON_SELF_MIXGATE(less_equal, operator<=, <=)
00356
00357 #define ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(NAME) \
00358 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE(NAME, NAME)
00359
00360 #define ARAGELI_ALL_EACH_ALL_CMP_FUNCTIONS_SELF_MIXGATE \
00361 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(each_equal_to) \
00362 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(each_not_equal_to) \
00363 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(each_greater) \
00364 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(each_less) \
00365 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(each_greater_equal) \
00366 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(each_less_equal) \
00367 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(all_equal_to) \
00368 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(all_not_equal_to) \
00369 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(all_greater) \
00370 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(all_less) \
00371 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(all_greater_equal) \
00372 ARAGELI_BINARY_FUNCTION_SELF_MIXGATE_SAMENAME(all_less_equal)
00373
00374
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386 #endif // #ifndef _ARAGELI_mixcomp_hpp_