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 #ifndef ACE_NUMERIC_LIMITS_H
00026 #define ACE_NUMERIC_LIMITS_H
00027
00028 #include "ace/pre.h"
00029
00030 #include "ace/ACE_export.h"
00031
00032 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00033 # pragma once
00034 # endif
00035
00036 #ifdef ACE_LACKS_NUMERIC_LIMITS
00037 # include "ace/Basic_Types.h"
00038 #else
00039
00040 # ifdef __MINGW32__
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 # undef min
00052 # undef max
00053 # endif
00054
00055 # if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00056
00057 # include "ace/Basic_Types.h"
00058 # endif
00059
00060 # include <limits>
00061 #endif
00062
00063
00064
00065 #undef min
00066 #undef max
00067
00068 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00069
00070 #ifdef ACE_LACKS_NUMERIC_LIMITS
00071
00072 template <typename T> struct ACE_Numeric_Limits;
00073
00074
00075
00076
00077 template<>
00078 struct ACE_Export ACE_Numeric_Limits<char>
00079 {
00080 static char min (void) { return CHAR_MIN; }
00081 static char max (void) { return CHAR_MAX; }
00082 };
00083
00084
00085
00086
00087 template<>
00088 struct ACE_Export ACE_Numeric_Limits<signed char>
00089 {
00090 static signed char min (void) { return SCHAR_MIN; }
00091 static signed char max (void) { return SCHAR_MAX; }
00092 };
00093
00094 template<>
00095 struct ACE_Export ACE_Numeric_Limits<signed short>
00096 {
00097 static signed short min (void) { return SHRT_MIN; }
00098 static signed short max (void) { return SHRT_MAX; }
00099 };
00100
00101 template<>
00102 struct ACE_Export ACE_Numeric_Limits<signed int>
00103 {
00104 static signed int min (void) { return INT_MIN; }
00105 static signed int max (void) { return INT_MAX; }
00106 };
00107
00108 template<>
00109 struct ACE_Export ACE_Numeric_Limits<signed long>
00110 {
00111 static signed long min (void) { return LONG_MIN; }
00112 static signed long max (void) { return LONG_MAX; }
00113 };
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 template<>
00147 struct ACE_Export ACE_Numeric_Limits<unsigned char>
00148 {
00149 static unsigned char min (void) { return 0; }
00150 static unsigned char max (void) { return UCHAR_MAX; }
00151 };
00152
00153 template<>
00154 struct ACE_Export ACE_Numeric_Limits<unsigned short>
00155 {
00156 static unsigned short min (void) { return 0; }
00157 static unsigned short max (void) { return USHRT_MAX; }
00158 };
00159
00160 template<>
00161 struct ACE_Export ACE_Numeric_Limits<unsigned int>
00162 {
00163 static unsigned int min (void) { return 0; }
00164 static unsigned int max (void) { return UINT_MAX; }
00165 };
00166
00167 template<>
00168 struct ACE_Export ACE_Numeric_Limits<unsigned long>
00169 {
00170 static unsigned long min (void) { return 0; }
00171 static unsigned long max (void) { return ULONG_MAX; }
00172 };
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 template<>
00196 struct ACE_Export ACE_Numeric_Limits<float>
00197 {
00198 static float min (void) { return FLT_MIN; }
00199 static float max (void) { return FLT_MAX; }
00200 };
00201
00202 template<>
00203 struct ACE_Export ACE_Numeric_Limits<double>
00204 {
00205 static double min (void) { return DBL_MIN; }
00206 static double max (void) { return DBL_MAX; }
00207 };
00208
00209 template<>
00210 struct ACE_Export ACE_Numeric_Limits<long double>
00211 {
00212 static long double min (void) { return LDBL_MIN; }
00213 static long double max (void) { return LDBL_MAX; }
00214 };
00215
00216 #else
00217
00218
00219
00220
00221 template <typename T>
00222 struct ACE_Numeric_Limits
00223 {
00224 static T min (void) { return std::numeric_limits<T>::min (); }
00225 static T max (void) { return std::numeric_limits<T>::max (); }
00226 };
00227
00228 # if (defined (ACE_WIN64) && defined (_MSC_VER) && _MSC_VER <= 1310) \
00229 || defined (ACE_LACKS_NUMERIC_LIMITS_64_BIT_TYPES)
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 template<>
00241 struct ACE_Numeric_Limits<LONGLONG>
00242 {
00243 static LONGLONG min (void) { return _I64_MIN; }
00244 static LONGLONG max (void) { return _I64_MAX; }
00245 };
00246
00247 template<>
00248 struct ACE_Numeric_Limits<ULONGLONG>
00249 {
00250 static ULONGLONG min (void) { return 0; }
00251 static ULONGLONG max (void) { return _UI64_MAX; }
00252 };
00253 # endif
00254
00255 #endif
00256
00257 #if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00258 template<>
00259 struct ACE_Numeric_Limits<ACE_U_LongLong>
00260 {
00261 static ACE_U_LongLong min (void) { return ACE_U_LongLong (); }
00262 static ACE_U_LongLong max (void) { return ACE_UINT64_MAX; }
00263 };
00264 #endif
00265
00266 ACE_END_VERSIONED_NAMESPACE_DECL
00267
00268 #include "ace/post.h"
00269
00270 #endif