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 METALIC_CMP_HH
00029 # define METALIC_CMP_HH
00030
00031 # include <mlc/bool.hh>
00032
00033 namespace mlc
00034 {
00035
00036
00037
00038
00039
00040 template <class T, class U>
00041 struct type_eq : returns_bool_<false> {};
00042
00043 template <class T>
00044 struct type_eq<T, T> : returns_bool_<true> {};
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 template<int i, int j>
00055 struct less
00056 {
00057 enum { ret = (i < j) };
00058 static void ensure() { is_true<ret>::ensure(); };
00059 };
00060
00061 template<int i, int j>
00062 struct lesseq
00063 {
00064 enum { ret = (i <= j) };
00065 static void ensure() { is_true<ret>::ensure(); };
00066 };
00067
00068 template<int i, int j>
00069 struct eq
00070 {
00071 enum { ret = (i == j) };
00072 static void ensure() { is_true<ret>::ensure(); };
00073 };
00074
00075 template<int i, int j>
00076 struct neq
00077 {
00078 enum { ret = (i != j) };
00079 static void ensure() { is_true<ret>::ensure(); };
00080 };
00081
00082 template<int i, int j>
00083 struct greater
00084 {
00085 enum { ret = (i > j) };
00086 static void ensure() { is_true<ret>::ensure(); };
00087 };
00088
00089 template<int i, int j>
00090 struct greatereq
00091 {
00092 enum { ret = (i >= j) };
00093 static void ensure() { is_true<ret>::ensure(); };
00094 };
00095
00096 template<int i, int j>
00097 struct min
00098 {
00099 enum { ret = (i < j ? i : j) };
00100 };
00101
00102 template<int i, int j>
00103 struct max
00104 {
00105 enum { ret = (i > j ? i : j) };
00106 };
00107
00108 template<int i, int j, int N>
00109 struct maxN
00110 {
00111 enum { ret = (i > j ?
00112 (i > N ? N : i) :
00113 (j > N ? N : j)) };
00114 };
00115
00116 template<int i, int N>
00117 struct saturateN
00118 {
00119 enum { ret = (i > N ? N : i) };
00120 };
00121
00122 }
00123
00124 #endif // ! METALIC_CMP_HH