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 #ifndef MLN_VALUE_BUILTIN_INTEGERS_HH
00027 # define MLN_VALUE_BUILTIN_INTEGERS_HH
00028
00032
00033 # include <mln/value/internal/limits.hh>
00034
00035 # include <mln/value/concept/built_in.hh>
00036 # include <mln/value/concept/integer.hh>
00037 # include <mln/trait/value_.hh>
00038
00039 # include <mln/metal/int.hh>
00040 # include <mln/metal/if.hh>
00041 # include <mln/metal/bool.hh>
00042
00043
00044 namespace mln
00045 {
00046
00047 template <> struct category< unsigned char > { typedef value::Built_In< value::Integer<void> > ret; };
00048 template <> struct category< signed char > { typedef value::Built_In< value::Integer<void> > ret; };
00049 template <> struct category< unsigned short > { typedef value::Built_In< value::Integer<void> > ret; };
00050 template <> struct category< signed short > { typedef value::Built_In< value::Integer<void> > ret; };
00051 template <> struct category< unsigned int > { typedef value::Built_In< value::Integer<void> > ret; };
00052 template <> struct category< signed int > { typedef value::Built_In< value::Integer<void> > ret; };
00053 template <> struct category< unsigned long > { typedef value::Built_In< value::Integer<void> > ret; };
00054 template <> struct category< signed long > { typedef value::Built_In< value::Integer<void> > ret; };
00055
00056
00057 namespace trait
00058 {
00059
00060
00061
00062 namespace internal
00063 {
00064
00065 template <typename E>
00066 struct value_integer_
00067 {
00068 private:
00069 enum { n = 8 * sizeof(E) };
00070 public:
00071
00072 enum {
00073 dim = 1,
00074 nbits = n,
00075 card = mln_value_card_from_(n)
00076 };
00077
00078 typedef trait::value::nature::integer nature;
00079 typedef trait::value::kind::data kind;
00080 typedef mln_value_quant_from_(card) quant;
00081
00082 static const E min() { return mln::value::internal::limits<E>::min(); }
00083 static const E max() { return mln::value::internal::limits<E>::max(); }
00084
00085 typedef float sum;
00086 };
00087
00088 }
00089
00090
00091 template <> struct value_< unsigned char >
00092 : internal::value_integer_< unsigned char >
00093 {
00094 static const char* name()
00095 { return "unsigned char"; }
00096 };
00097
00098 template <> struct value_< signed char >
00099 : internal::value_integer_< signed char >
00100 {
00101 static const char* name()
00102 { return "signed char"; }
00103 };
00104
00105 template <> struct value_< char >
00106 : internal::value_integer_< signed char >
00107 {
00108 static const char* name()
00109 { return "char"; }
00110 };
00111
00112 template <> struct value_< unsigned short >
00113 : internal::value_integer_< unsigned short >
00114 {
00115 static const char* name()
00116 { return "unsigned short"; }
00117 };
00118
00119 template <> struct value_< signed short >
00120 : internal::value_integer_< signed short >
00121 {
00122 static const char* name()
00123 { return "signed short"; }
00124 };
00125
00126 template <> struct value_< unsigned int >
00127 : internal::value_integer_< unsigned int >
00128 {
00129 static const char* name()
00130 { return "unsigned int"; }
00131 };
00132
00133 template <> struct value_< signed int >
00134 : internal::value_integer_< signed int >
00135 {
00136 static const char* name()
00137 { return "signed int"; }
00138 };
00139
00140 template <> struct value_< unsigned long >
00141 : internal::value_integer_< unsigned long >
00142 {
00143 static const char* name()
00144 { return "unsigned long"; }
00145 };
00146
00147 template <> struct value_< signed long >
00148 : internal::value_integer_< signed long >
00149 {
00150 static const char* name()
00151 { return "signed long"; }
00152 };
00153
00154 }
00155
00156 }
00157
00158
00159 #endif // ! MLN_VALUE_BUILTIN_INTEGERS_HH