realroot_doc 0.1.1
|
00001 #ifndef realroot_BASE_TYPE_TESTS_H 00002 #define realroot_BASE_TYPE_TESTS_H 00003 00004 #include <realroot/texp_bool.hpp> 00005 00006 namespace mmx { 00007 00008 namespace texp 00009 { 00010 00012 template <class X, class Y> 00013 struct equal 00014 { 00015 enum { V = 1 }; 00016 typedef false_t T; 00017 }; 00018 00019 template<class X> 00020 struct equal<X,X> 00021 { 00022 enum { V = 1 }; 00023 typedef true_t T; 00024 }; 00025 00027 template<class X, class A, class B> 00028 struct tselect { typedef A T; }; 00029 template<class A, class B> 00030 struct tselect<false_t, A, B> { typedef B T; }; 00031 template<class A, class B> 00032 struct tselect<null_t,A, B> { typedef B T; }; 00033 00035 template<int k, class A, class B> 00036 struct vselect { typedef A T; }; 00037 template<class A, class B> 00038 struct vselect<0,A,B> { typedef B T; }; 00039 00040 template< typename X > 00041 struct tnot 00042 { 00043 typedef false_t T; 00044 }; 00045 00046 template<> 00047 struct tnot< false_t > { typedef true_t T; }; 00048 template<> 00049 struct tnot< null_t > { typedef true_t T; }; 00050 template<class X> 00051 struct is_ptr{ typedef typename equal<X,typename ptr<X>::T >::T T; }; 00052 00053 template<bool test, class A, class B> 00054 struct If 00055 { 00056 typedef A result_t; 00057 }; 00058 00059 template<class A,class B> 00060 struct If<false,A,B> 00061 { 00062 typedef B result_t; 00063 }; 00064 00065 template<class A,class B> 00066 struct Eq 00067 { 00068 enum { result = 0 }; 00069 typedef false_t result_t; 00070 }; 00071 00072 template<class A> 00073 struct Eq<A,A> 00074 { 00075 enum { result = 1 }; 00076 typedef true_t result_t; 00077 }; 00078 00079 template<class A> 00080 struct ValueType 00081 { 00082 typedef typename A::value_type result_t; 00083 }; 00084 00085 template<class A, int n > 00086 struct ValueType< A[n] > 00087 { 00088 typedef A result_t; 00089 }; 00090 template<class A> 00091 struct ValueType<A*> 00092 { 00093 typedef A result_t; 00094 }; 00095 00096 template<int n> 00097 struct Int {}; 00098 00099 template<bool b> struct BoolType { typedef false_t result_t; }; 00100 template<> struct BoolType<true> { typedef true_t result_t; }; 00101 00102 template<class X> 00103 struct deconst{ 00104 typedef X result_t; 00105 }; 00106 00107 template<class X> 00108 struct deconst< const X> { typedef X result_t; }; 00109 00110 template<class A,class B> 00111 struct Sup 00112 { 00113 typedef typename deconst<A>::result_t result_t; 00114 }; 00115 00116 template<class el, class nx> 00117 struct Pair 00118 { 00119 typedef el element_t; 00120 typedef nx next_t; 00121 }; 00122 00123 }// namespace texp 00124 00125 #define typelist1(a) Type::Pair< a, Type::null_t > 00126 #define typelist2(a,b) Type::Pair< a, typelist1(b) > 00127 #define typelist3(a,b,c) Type::Pair< a, typelist2(b,c) > 00128 #define typelist4(a,b,c) Type::Pair< a, typelist3(b,c,d) > 00129 00130 00131 00132 00133 00134 00135 00136 }// end namespace mmx 00137 00138 #endif