00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00030 #ifndef _EXMAT_TYPETRAITS_H
00031 #define _EXMAT_TYPETRAITS_H
00032
00033 #include <limits>
00034 #include "PlatformSpec.h"
00035 #include "Metaprogramming.h"
00036
00037 namespace exmat {
00038
00039
00040
00041
00042
00043
00044
00045 template<class A, class B>
00046 struct TypeTraits
00047 {
00048 typedef typename IF<
00049 OR_bool<
00050 LESS<
00051 std::numeric_limits<A>::max_exponent10, std::numeric_limits<B>::max_exponent10
00052 >::RET,
00053 AND_bool<
00054 EQUAL<
00055 std::numeric_limits<A>::max_exponent10, std::numeric_limits<B>::max_exponent10
00056 >::RET,
00057 LESS<
00058 std::numeric_limits<A>::digits, std::numeric_limits<B>::digits
00059 >::RET
00060 >::RET
00061 >::RET,
00062 B, A>::RET HigherValue;
00063 typedef typename IF<
00064 OR_bool<
00065 LESS<
00066 std::numeric_limits<A>::max_exponent10, std::numeric_limits<B>::max_exponent10
00067 >::RET,
00068 AND_bool<
00069 EQUAL<
00070 std::numeric_limits<A>::max_exponent10, std::numeric_limits<B>::max_exponent10
00071 >::RET,
00072 LESS<
00073 std::numeric_limits<A>::digits, std::numeric_limits<B>::digits
00074 >::RET
00075 >::RET
00076 >::RET,
00077 A, B>::RET LowerValue;
00078 };
00079
00080
00081 #define TYPETRAITS_SPEC(T1, T2, RT1, RT2) \
00082 template<> struct TypeTraits<T1, T2> { \
00083 typedef RT1 HigherValue; \
00084 typedef RT2 LowerValue; \
00085 };
00086 TYPETRAITS_SPEC(int, int, int, int);
00087 TYPETRAITS_SPEC(float, float, float, float);
00088 TYPETRAITS_SPEC(double, double, double, double);
00089 #undef TYPETRAITS_SPEC
00090
00091 #define HEleType(T1, T2) typename TypeTraits<T1, T2>::HigherValue
00092 #define LEleType(T1, T2) typename TypeTraits<T1, T2>::LowerValue
00093
00094 }
00095
00096 #endif // _EXMAT_TYPETRAITS_H