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 NTG_REAL_OPTRAITS_BUILTIN_INT_HH
00029 # define NTG_REAL_OPTRAITS_BUILTIN_INT_HH
00030
00031
00032
00033
00034
00035 # include <ntg/config/system.hh>
00036 # include <ntg/real/optraits_real.hh>
00037 # include <ntg/real/typetraits_builtin_int.hh>
00038
00039
00040 # include <limits.h>
00041
00042 # include <string>
00043
00044
00045
00046
00047
00048 # define OPTRAITS_BUILTIN_INT_U(Name, Max) \
00049 template <> \
00050 struct optraits<Name > : public optraits<uint_value<Name > > \
00051 { \
00052 static Name max() { return Max; } \
00053 static std::string name() { return std::string(#Name); } \
00054 }
00055
00056 # define OPTRAITS_BUILTIN_INT_S(Name, Min, Max) \
00057 template <> \
00058 struct optraits<Name > : public optraits<sint_value<Name > > \
00059 { \
00060 static Name min() { return Min; } \
00061 static Name max() { return Max; } \
00062 static std::string name() { return std::string(#Name); } \
00063 }
00064
00065 namespace ntg {
00066
00067 namespace internal {
00068
00069
00070
00071
00072
00073
00074
00075 OPTRAITS_BUILTIN_INT_U(unsigned long, ULONG_MAX);
00076 OPTRAITS_BUILTIN_INT_U(unsigned int, UINT_MAX);
00077 OPTRAITS_BUILTIN_INT_U(unsigned short, USHRT_MAX);
00078 OPTRAITS_BUILTIN_INT_U(unsigned char, UCHAR_MAX);
00079
00080 OPTRAITS_BUILTIN_INT_S(signed long, LONG_MIN, LONG_MAX);
00081 OPTRAITS_BUILTIN_INT_S(signed int, INT_MIN, INT_MAX);
00082 OPTRAITS_BUILTIN_INT_S(signed short, SHRT_MIN, SHRT_MAX);
00083
00084 OPTRAITS_BUILTIN_INT_S(signed char, CHAR_MIN, CHAR_MAX);
00085
00086 OPTRAITS_BUILTIN_INT_S(char, CHAR_MIN, CHAR_MAX);
00087
00088 }
00089
00090 }
00091
00092 #endif // !NTG_REAL_OPTRAITS_BUILTIN_INT_HH