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 #ifndef NTG_CORE_INTERNAL_GLOBAL_OPS_DEFS_HH
00029 # define NTG_CORE_INTERNAL_GLOBAL_OPS_DEFS_HH
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 # define GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, Builtin) \
00061 template <class T2> inline \
00062 Builtin& \
00063 Op(Builtin& lhs, const value<T2>& rhs) \
00064 { return optraits<Builtin>::Name(lhs, rhs.exact()); }
00065
00066
00067
00068
00069
00070 # define GLOBAL_ASSIGN_OP_BUILTIN_INT(Op, Name) \
00071 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, signed long) \
00072 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, unsigned long) \
00073 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, signed int) \
00074 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, unsigned int) \
00075 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, signed short) \
00076 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, unsigned short) \
00077 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, char) \
00078 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, signed char) \
00079 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, unsigned char)
00080
00081 # define GLOBAL_ASSIGN_OP_BUILTIN_FLOAT(Op, Name) \
00082 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, float) \
00083 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, double)
00084
00085 # define GLOBAL_ASSIGN_OP_BUILTIN_BOOL(Op, Name) \
00086 GLOBAL_ASSIGN_OP_BUILTIN(Op, Name, bool)
00087
00088 # define GLOBAL_ASSIGN_OP(Op, Name) \
00089 template <class T1, class T2> inline \
00090 T1& \
00091 Op(value<T1>& lhs, const T2& rhs) \
00092 { return optraits<T1>::Name(lhs.exact(), rhs); }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 # define GLOBAL_ARITH_OP_BUILTIN(Op, Name, Builtin) \
00103 template <class T2> inline \
00104 ntg_return_type(Name, Builtin, T2) \
00105 Op(Builtin lhs, const value<T2>& rhs) \
00106 { \
00107 typedef ntg_deduced_traits_type(Name, Builtin, T2) deduced_type; \
00108 \
00109 typedef typename deduced_type::impl impl; \
00110 typedef typename deduced_type::lhs_type lhs_type; \
00111 typedef typename deduced_type::rhs_type rhs_type; \
00112 \
00113 return optraits<impl>::Name(static_cast<lhs_type>(lhs), \
00114 static_cast<rhs_type>(rhs.exact())); \
00115 }
00116
00117
00118
00119
00120
00121 # define GLOBAL_ARITH_OP(Op, Name) \
00122 template <class T1, class T2> inline \
00123 ntg_return_type(Name, T1, T2) \
00124 Op(const value<T1>& lhs, const T2& rhs) \
00125 { \
00126
00127
00128
00129 \
00130 \
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 \
00142 \
00143 typedef ntg_deduced_traits_type(Name, T1, T2) deduced_type; \
00144 \
00145 typedef typename deduced_type::impl impl; \
00146 typedef typename deduced_type::lhs_type lhs_type; \
00147 typedef typename deduced_type::rhs_type rhs_type; \
00148 \
00149 return optraits<impl>::Name(static_cast<lhs_type>(lhs.exact()), \
00150 static_cast<rhs_type>(rhs)); \
00151 } \
00152 \
00153 GLOBAL_ARITH_OP_BUILTIN(Op, Name, signed long) \
00154 GLOBAL_ARITH_OP_BUILTIN(Op, Name, unsigned long) \
00155 GLOBAL_ARITH_OP_BUILTIN(Op, Name, signed int) \
00156 GLOBAL_ARITH_OP_BUILTIN(Op, Name, unsigned int) \
00157 GLOBAL_ARITH_OP_BUILTIN(Op, Name, signed short) \
00158 GLOBAL_ARITH_OP_BUILTIN(Op, Name, unsigned short) \
00159 GLOBAL_ARITH_OP_BUILTIN(Op, Name, signed char) \
00160 GLOBAL_ARITH_OP_BUILTIN(Op, Name, unsigned char) \
00161 GLOBAL_ARITH_OP_BUILTIN(Op, Name, char) \
00162 GLOBAL_ARITH_OP_BUILTIN(Op, Name, float) \
00163 GLOBAL_ARITH_OP_BUILTIN(Op, Name, double) \
00164 GLOBAL_ARITH_OP_BUILTIN(Op, Name, bool)
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 # define GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, Builtin) \
00175 template <class T2> inline \
00176 ntg_return_type(logical, Builtin, T2) \
00177 Op(const Builtin& lhs, const value<T2>& rhs) \
00178 { \
00179 typedef ntg_deduced_traits_type(logical, Builtin, T2) deduced_type; \
00180 \
00181 typedef typename deduced_type::impl impl; \
00182 typedef typename deduced_type::lhs_type lhs_type; \
00183 typedef typename deduced_type::rhs_type rhs_type; \
00184 \
00185 return optraits<impl>::Name(static_cast<lhs_type>(lhs), \
00186 static_cast<rhs_type>(rhs.exact())); \
00187 }
00188
00189
00190
00191
00192
00193 # define GLOBAL_LOGICAL_OP(Op, Name) \
00194 template <class T1, class T2> inline \
00195 ntg_return_type(logical, T1, T2) \
00196 Op(const value<T1>& lhs, const T2& rhs) \
00197 { \
00198 typedef ntg_deduced_traits_type(logical, T1, T2) deduced_type; \
00199 \
00200 typedef typename deduced_type::impl impl; \
00201 typedef typename deduced_type::lhs_type lhs_type; \
00202 typedef typename deduced_type::rhs_type rhs_type; \
00203 \
00204 return optraits<impl>::Name(static_cast<lhs_type>(lhs.exact()), \
00205 static_cast<rhs_type>(rhs)); \
00206 } \
00207 \
00208 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, signed long) \
00209 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, unsigned long) \
00210 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, signed int) \
00211 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, unsigned int) \
00212 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, signed short) \
00213 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, unsigned short) \
00214 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, signed char) \
00215 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, unsigned char) \
00216 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, float) \
00217 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, double) \
00218 GLOBAL_LOGICAL_OP_BUILTIN(Op, Name, bool)
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 # define GLOBAL_CMP_OP_BUILTIN(Op, Name, Builtin) \
00229 template <class T2> inline \
00230 bool \
00231 Op(const Builtin& lhs, const value<T2>& rhs) \
00232 { \
00233 typedef ntg_deduced_traits_type(cmp, Builtin, T2) deduced_type; \
00234 \
00235 typedef typename deduced_type::impl impl; \
00236 typedef typename deduced_type::lhs_type lhs_type; \
00237 typedef typename deduced_type::rhs_type rhs_type; \
00238 \
00239 return optraits<impl>::Name(static_cast<lhs_type>(lhs), \
00240 static_cast<rhs_type>(rhs.exact())); \
00241 }
00242
00243
00244
00245
00246
00247 # define GLOBAL_CMP_OP(Op, Name) \
00248 template <class T1, class T2> inline \
00249 bool \
00250 Op(const value<T1>& lhs, const T2& rhs) \
00251 { \
00252 typedef ntg_deduced_traits_type(cmp, T1, T2) deduced_type; \
00253 \
00254 typedef typename deduced_type::impl impl; \
00255 typedef typename deduced_type::lhs_type lhs_type; \
00256 typedef typename deduced_type::rhs_type rhs_type; \
00257 \
00258 return optraits<impl>::Name(static_cast<lhs_type>(lhs.exact()), \
00259 static_cast<rhs_type>(rhs)); \
00260 } \
00261 \
00262 GLOBAL_CMP_OP_BUILTIN(Op, Name, signed long) \
00263 GLOBAL_CMP_OP_BUILTIN(Op, Name, unsigned long) \
00264 GLOBAL_CMP_OP_BUILTIN(Op, Name, signed int) \
00265 GLOBAL_CMP_OP_BUILTIN(Op, Name, unsigned int) \
00266 GLOBAL_CMP_OP_BUILTIN(Op, Name, signed short) \
00267 GLOBAL_CMP_OP_BUILTIN(Op, Name, unsigned short) \
00268 GLOBAL_CMP_OP_BUILTIN(Op, Name, signed char) \
00269 GLOBAL_CMP_OP_BUILTIN(Op, Name, unsigned char) \
00270 GLOBAL_CMP_OP_BUILTIN(Op, Name, float) \
00271 GLOBAL_CMP_OP_BUILTIN(Op, Name, double) \
00272 GLOBAL_CMP_OP_BUILTIN(Op, Name, bool)
00273
00274 #endif // !NTG_CORE_INTERNAL_GLOBAL_OPS_DEFS_HH