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
00029
00030
00031
00032
00033
00034
00035 #ifndef LEMON_UTILITY_H
00036 #define LEMON_UTILITY_H
00037
00043
00044
00045 namespace lemon
00046 {
00047
00049
00056 struct True {
00058 static const bool value = true;
00059 };
00060
00062
00066 struct False {
00068 static const bool value = false;
00069 };
00070
00071 template <bool left, bool right>
00072 struct _CompileTimeAnd {
00073 static const bool value = false;
00074 };
00075
00076 template <>
00077 struct _CompileTimeAnd<true, true> {
00078 static const bool value = true;
00079 };
00080
00081 template <typename Left, typename Right>
00082 struct CompileTimeAnd {
00083 static const bool value =
00084 _CompileTimeAnd<Left::value, Right::value>::value;
00085 };
00086
00087 template <typename T>
00088 struct Wrap {
00089 const T &value;
00090 Wrap(const T &t) : value(t) {}
00091 };
00092
00093
00094
00095 template<int T> struct dummy { dummy(int) {} };
00096
00097
00098
00099 template <bool B, class T = void>
00100 struct enable_if_c {
00101 typedef T type;
00102 };
00103
00104 template <class T>
00105 struct enable_if_c<false, T> {};
00106
00107 template <class Cond, class T = void>
00108 struct enable_if : public enable_if_c<Cond::value, T> {};
00109
00110 template <bool B, class T>
00111 struct lazy_enable_if_c {
00112 typedef typename T::type type;
00113 };
00114
00115 template <class T>
00116 struct lazy_enable_if_c<false, T> {};
00117
00118 template <class Cond, class T>
00119 struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
00120
00121
00122 template <bool B, class T = void>
00123 struct disable_if_c {
00124 typedef T type;
00125 };
00126
00127 template <class T>
00128 struct disable_if_c<true, T> {};
00129
00130 template <class Cond, class T = void>
00131 struct disable_if : public disable_if_c<Cond::value, T> {};
00132
00133 template <bool B, class T>
00134 struct lazy_disable_if_c {
00135 typedef typename T::type type;
00136 };
00137
00138 template <class T>
00139 struct lazy_disable_if_c<true, T> {};
00140
00141 template <class Cond, class T>
00142 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
00143
00144 }
00145
00146 #endif