BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
limits.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_COMMON_LIMITS_H
6 #define BALL_COMMON_LIMITS_H
7 
8 #ifndef BALL_CONFIG_CONFIG_H
9 # include <BALL/CONFIG/config.h>
10 #endif
11 
12 #ifndef BALL_COMMON_GLOBAL_H
13 # include <BALL/COMMON/global.h>
14 #endif
15 
16 #ifdef BALL_HAS_NUMERIC_LIMITS
17 # include <limits>
18 #else
19 # ifdef BALL_HAS_LIMITS_H
20 # include <limits.h>
21 # endif
22 # ifdef BALL_HAS_VALUES_H
23 # include <limits.h>
24 # endif
25 #endif
26 
27 # ifdef BALL_HAS_FLOAT_H
28 # include <float.h>
29 # endif
30 
31 namespace BALL
32 {
33 
34 
46  template <typename T>
48  {
49  public:
50 
51 #ifdef BALL_HAS_NUMERIC_LIMITS
52 
53 
57  static T min()
58  {
60  }
61 
65  static T max()
66  {
68  }
69 #else
70  static T min()
71  {
72  return (T)0;
73  }
74  static T max()
75  {
76  return (T)0;
77  }
78 #endif
79  };
80 
81 #ifndef BALL_HAS_NUMERIC_LIMITS
82 
83  template <>
85  {
86  public:
87 
88  static float min()
89  {
90  return FLT_MIN;
91  }
92 
93  static float max()
94  {
95  return FLT_MAX;
96  }
97  };
98 
99  template <>
101  {
102  public:
103 
104  static double min()
105  {
106  return DBL_MIN;
107  }
108 
109  static double max()
110  {
111  return DBL_MAX;
112  }
113  };
114 
115  template <>
117  {
118  public:
119 
120  static bool min()
121  {
122  return false;
123  }
124 
125  static bool max()
126  {
127  return true;
128  }
129  };
130 
131  template <>
132  class BALL_EXPORT Limits<char>
133  {
134  public:
135 
136  static char min()
137  {
138  return CHAR_MIN;
139  }
140 
141  static char max()
142  {
143  return CHAR_MAX;
144  }
145  };
146 
147  template <>
148  class BALL_EXPORT Limits<signed char>
149  {
150  public:
151 
152  static signed char min()
153  {
154  return SCHAR_MIN;
155  }
156 
157  static signed char max()
158  {
159  return SCHAR_MAX;
160  }
161  };
162 
163  template <>
164  class BALL_EXPORT Limits<unsigned char>
165  {
166  public:
167 
168  static unsigned char min()
169  {
170  return 0;
171  }
172 
173  static unsigned char max()
174  {
175  return UCHAR_MAX;
176  }
177  };
178 
179  template <>
180  class BALL_EXPORT Limits<short>
181  {
182  public:
183 
184  static short min()
185  {
186  return SHRT_MIN;
187  }
188 
189  static short max()
190  {
191  return SHRT_MAX;
192  }
193  };
194 
195  template <>
196  class BALL_EXPORT Limits<unsigned short>
197  {
198  public:
199 
200  static unsigned short min()
201  {
202  return 0;
203  }
204 
205  static unsigned short max()
206  {
207  return USHRT_MAX;
208  }
209  };
210 
211  template <>
212  class BALL_EXPORT Limits<int>
213  {
214  public:
215 
216  static int min()
217  {
218  return INT_MIN;
219  }
220 
221  static int max()
222  {
223  return INT_MAX;
224  }
225  };
226 
227  template <>
228  class BALL_EXPORT Limits<unsigned int>
229  {
230  public:
231 
232  static unsigned int min()
233  {
234  return 0;
235  }
236 
237  static unsigned int max()
238  {
239  return UINT_MAX;
240  }
241  };
242 
243  template <>
244  class BALL_EXPORT Limits<long>
245  {
246  public:
247 
248  static long min()
249  {
250  return LONG_MIN;
251  }
252 
253  static long max()
254  {
255  return LONG_MAX;
256  }
257  };
258 
259  template <>
260  class BALL_EXPORT Limits<unsigned long>
261  {
262  public:
263 
264  static unsigned long min()
265  {
266  return 0;
267  }
268 
269  static unsigned long max()
270  {
271  return ULONG_MAX;
272  }
273  };
274 
275 #endif // BALL_HAS_NUMERIC_LIMITS
276 
277 } // namespace BALL
278 
279 #endif // BALL_COMMON_LIMITS_H
static int max()
Definition: limits.h:221
static bool max()
Definition: limits.h:125
static char max()
Definition: limits.h:141
static long min()
Definition: limits.h:248
static signed char max()
Definition: limits.h:157
static int min()
Definition: limits.h:216
static unsigned int min()
Definition: limits.h:232
static short max()
Definition: limits.h:189
static unsigned char min()
Definition: limits.h:168
static double min()
Definition: limits.h:104
#define BALL_DEPRECATED
Definition: COMMON/global.h:66
static double max()
Definition: limits.h:109
static bool min()
Definition: limits.h:120
static float min()
Definition: limits.h:88
static unsigned char max()
Definition: limits.h:173
static unsigned long min()
Definition: limits.h:264
T max(const T &a, const T &b)
Definition: MATHS/common.h:79
static unsigned short min()
Definition: limits.h:200
static unsigned int max()
Definition: limits.h:237
static long max()
Definition: limits.h:253
static T max()
Definition: limits.h:74
static float max()
Definition: limits.h:93
static short min()
Definition: limits.h:184
static unsigned short max()
Definition: limits.h:205
static unsigned long max()
Definition: limits.h:269
static signed char min()
Definition: limits.h:152
static T min()
Definition: limits.h:70
#define BALL_EXPORT
Definition: COMMON/global.h:50
static char min()
Definition: limits.h:136
T min(const T &a, const T &b)
Definition: MATHS/common.h:106