blob: 14b49b1385b387a0975916c357d2e2d6a4289466 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- limits ----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_LIMITS
12#define _LIBCPP_LIMITS
13
14/*
15 limits synopsis
16
17namespace std
18{
19
20template<class T>
21class numeric_limits
22{
23public:
24 static const bool is_specialized = false;
Howard Hinnanted569212011-05-26 18:23:59 +000025 static T min() noexcept;
26 static T max() noexcept;
27 static T lowest() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000028
29 static const int digits = 0;
30 static const int digits10 = 0;
31 static const int max_digits10 = 0;
32 static const bool is_signed = false;
33 static const bool is_integer = false;
34 static const bool is_exact = false;
35 static const int radix = 0;
Howard Hinnanted569212011-05-26 18:23:59 +000036 static T epsilon() noexcept;
37 static T round_error() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000038
39 static const int min_exponent = 0;
40 static const int min_exponent10 = 0;
41 static const int max_exponent = 0;
42 static const int max_exponent10 = 0;
43
44 static const bool has_infinity = false;
45 static const bool has_quiet_NaN = false;
46 static const bool has_signaling_NaN = false;
47 static const float_denorm_style has_denorm = denorm_absent;
48 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +000049 static T infinity() noexcept;
50 static T quiet_NaN() noexcept;
51 static T signaling_NaN() noexcept;
52 static T denorm_min() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000053
54 static const bool is_iec559 = false;
55 static const bool is_bounded = false;
56 static const bool is_modulo = false;
57
58 static const bool traps = false;
59 static const bool tinyness_before = false;
60 static const float_round_style round_style = round_toward_zero;
61};
62
63enum float_round_style
64{
65 round_indeterminate = -1,
66 round_toward_zero = 0,
67 round_to_nearest = 1,
68 round_toward_infinity = 2,
69 round_toward_neg_infinity = 3
70};
71
72enum float_denorm_style
73{
74 denorm_indeterminate = -1,
75 denorm_absent = 0,
76 denorm_present = 1
77};
78
79template<> class numeric_limits<cv bool>;
80
81template<> class numeric_limits<cv char>;
82template<> class numeric_limits<cv signed char>;
83template<> class numeric_limits<cv unsigned char>;
84template<> class numeric_limits<cv wchar_t>;
85template<> class numeric_limits<cv char16_t>;
86template<> class numeric_limits<cv char32_t>;
87
88template<> class numeric_limits<cv short>;
89template<> class numeric_limits<cv int>;
90template<> class numeric_limits<cv long>;
91template<> class numeric_limits<cv long long>;
92template<> class numeric_limits<cv unsigned short>;
93template<> class numeric_limits<cv unsigned int>;
94template<> class numeric_limits<cv unsigned long>;
95template<> class numeric_limits<cv unsigned long long>;
96
97template<> class numeric_limits<cv float>;
98template<> class numeric_limits<cv double>;
99template<> class numeric_limits<cv long double>;
100
101} // std
102
103*/
104
Howard Hinnant08e17472011-10-17 20:05:10 +0000105#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000106#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000107#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000108
109#include <__config>
110#include <type_traits>
111
Howard Hinnant78b68282011-10-22 20:59:45 +0000112#if defined(_MSC_VER)
113#include "support/win32/limits_win32.h"
114#endif // _MSC_VER
115
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000116_LIBCPP_BEGIN_NAMESPACE_STD
117
118enum float_round_style
119{
120 round_indeterminate = -1,
121 round_toward_zero = 0,
122 round_to_nearest = 1,
123 round_toward_infinity = 2,
124 round_toward_neg_infinity = 3
125};
126
127enum float_denorm_style
128{
129 denorm_indeterminate = -1,
130 denorm_absent = 0,
131 denorm_present = 1
132};
133
134template <class _Tp, bool = is_arithmetic<_Tp>::value>
135class __libcpp_numeric_limits
136{
137protected:
138 typedef _Tp type;
139
140 static const bool is_specialized = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000141 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return type();}
142 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return type();}
143 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000144
145 static const int digits = 0;
146 static const int digits10 = 0;
147 static const int max_digits10 = 0;
148 static const bool is_signed = false;
149 static const bool is_integer = false;
150 static const bool is_exact = false;
151 static const int radix = 0;
Howard Hinnanted569212011-05-26 18:23:59 +0000152 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return type();}
153 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000154
155 static const int min_exponent = 0;
156 static const int min_exponent10 = 0;
157 static const int max_exponent = 0;
158 static const int max_exponent10 = 0;
159
160 static const bool has_infinity = false;
161 static const bool has_quiet_NaN = false;
162 static const bool has_signaling_NaN = false;
163 static const float_denorm_style has_denorm = denorm_absent;
164 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000165 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return type();}
166 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return type();}
167 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return type();}
168 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000169
170 static const bool is_iec559 = false;
171 static const bool is_bounded = false;
172 static const bool is_modulo = false;
173
174 static const bool traps = false;
175 static const bool tinyness_before = false;
176 static const float_round_style round_style = round_toward_zero;
177};
178
179template <class _Tp, int digits, bool is_signed>
180struct __libcpp_compute_min
181{
182 static const _Tp value = _Tp(_Tp(1) << digits);
183};
184
185template <class _Tp, int digits>
186struct __libcpp_compute_min<_Tp, digits, false>
187{
188 static const _Tp value = _Tp(0);
189};
190
191template <class _Tp>
192class __libcpp_numeric_limits<_Tp, true>
193{
194protected:
195 typedef _Tp type;
196
197 static const bool is_specialized = true;
198
199 static const bool is_signed = type(-1) < type(0);
200 static const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
201 static const int digits10 = digits * 3 / 10;
202 static const int max_digits10 = 0;
203 static const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
204 static const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
Howard Hinnanted569212011-05-26 18:23:59 +0000205 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __min;}
206 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __max;}
207 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000208
209 static const bool is_integer = true;
210 static const bool is_exact = true;
211 static const int radix = 2;
Howard Hinnanted569212011-05-26 18:23:59 +0000212 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return type(0);}
213 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000214
215 static const int min_exponent = 0;
216 static const int min_exponent10 = 0;
217 static const int max_exponent = 0;
218 static const int max_exponent10 = 0;
219
220 static const bool has_infinity = false;
221 static const bool has_quiet_NaN = false;
222 static const bool has_signaling_NaN = false;
223 static const float_denorm_style has_denorm = denorm_absent;
224 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000225 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return type(0);}
226 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return type(0);}
227 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return type(0);}
228 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000229
230 static const bool is_iec559 = false;
231 static const bool is_bounded = true;
232 static const bool is_modulo = true;
233
234#if __i386__ || __x86_64__
235 static const bool traps = true;
236#else
237 static const bool traps = false;
238#endif
239 static const bool tinyness_before = false;
240 static const float_round_style round_style = round_toward_zero;
241};
242
243template <>
244class __libcpp_numeric_limits<bool, true>
245{
246protected:
247 typedef bool type;
248
249 static const bool is_specialized = true;
250
251 static const bool is_signed = false;
252 static const int digits = 1;
253 static const int digits10 = 0;
254 static const int max_digits10 = 0;
255 static const type __min = false;
256 static const type __max = true;
Howard Hinnanted569212011-05-26 18:23:59 +0000257 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __min;}
258 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __max;}
259 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000260
261 static const bool is_integer = true;
262 static const bool is_exact = true;
263 static const int radix = 2;
Howard Hinnanted569212011-05-26 18:23:59 +0000264 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return type(0);}
265 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000266
267 static const int min_exponent = 0;
268 static const int min_exponent10 = 0;
269 static const int max_exponent = 0;
270 static const int max_exponent10 = 0;
271
272 static const bool has_infinity = false;
273 static const bool has_quiet_NaN = false;
274 static const bool has_signaling_NaN = false;
275 static const float_denorm_style has_denorm = denorm_absent;
276 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000277 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return type(0);}
278 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return type(0);}
279 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return type(0);}
280 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000281
282 static const bool is_iec559 = false;
283 static const bool is_bounded = true;
284 static const bool is_modulo = false;
285
286 static const bool traps = false;
287 static const bool tinyness_before = false;
288 static const float_round_style round_style = round_toward_zero;
289};
290
291template <>
292class __libcpp_numeric_limits<float, true>
293{
294protected:
295 typedef float type;
296
297 static const bool is_specialized = true;
298
299 static const bool is_signed = true;
300 static const int digits = __FLT_MANT_DIG__;
301 static const int digits10 = __FLT_DIG__;
302 static const int max_digits10 = 2+(digits * 30103)/100000;
Howard Hinnanted569212011-05-26 18:23:59 +0000303 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __FLT_MIN__;}
304 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __FLT_MAX__;}
305 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000306
307 static const bool is_integer = false;
308 static const bool is_exact = false;
309 static const int radix = __FLT_RADIX__;
Howard Hinnanted569212011-05-26 18:23:59 +0000310 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __FLT_EPSILON__;}
311 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return 0.5F;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000312
313 static const int min_exponent = __FLT_MIN_EXP__;
314 static const int min_exponent10 = __FLT_MIN_10_EXP__;
315 static const int max_exponent = __FLT_MAX_EXP__;
316 static const int max_exponent10 = __FLT_MAX_10_EXP__;
317
318 static const bool has_infinity = true;
319 static const bool has_quiet_NaN = true;
320 static const bool has_signaling_NaN = true;
321 static const float_denorm_style has_denorm = denorm_present;
322 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000323 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __builtin_huge_valf();}
324 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __builtin_nanf("");}
325 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __builtin_nansf("");}
326 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __FLT_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000327
328 static const bool is_iec559 = true;
329 static const bool is_bounded = true;
330 static const bool is_modulo = false;
331
332 static const bool traps = false;
333 static const bool tinyness_before = false;
334 static const float_round_style round_style = round_to_nearest;
335};
336
337template <>
338class __libcpp_numeric_limits<double, true>
339{
340protected:
341 typedef double type;
342
343 static const bool is_specialized = true;
344
345 static const bool is_signed = true;
346 static const int digits = __DBL_MANT_DIG__;
347 static const int digits10 = __DBL_DIG__;
348 static const int max_digits10 = 2+(digits * 30103)/100000;
Howard Hinnanted569212011-05-26 18:23:59 +0000349 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __DBL_MIN__;}
350 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __DBL_MAX__;}
351 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000352
353 static const bool is_integer = false;
354 static const bool is_exact = false;
355 static const int radix = __FLT_RADIX__;
Howard Hinnanted569212011-05-26 18:23:59 +0000356 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __DBL_EPSILON__;}
357 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return 0.5;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000358
359 static const int min_exponent = __DBL_MIN_EXP__;
360 static const int min_exponent10 = __DBL_MIN_10_EXP__;
361 static const int max_exponent = __DBL_MAX_EXP__;
362 static const int max_exponent10 = __DBL_MAX_10_EXP__;
363
364 static const bool has_infinity = true;
365 static const bool has_quiet_NaN = true;
366 static const bool has_signaling_NaN = true;
367 static const float_denorm_style has_denorm = denorm_present;
368 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000369 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __builtin_huge_val();}
370 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __builtin_nan("");}
371 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __builtin_nans("");}
372 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __DBL_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000373
374 static const bool is_iec559 = true;
375 static const bool is_bounded = true;
376 static const bool is_modulo = false;
377
378 static const bool traps = false;
379 static const bool tinyness_before = false;
380 static const float_round_style round_style = round_to_nearest;
381};
382
383template <>
384class __libcpp_numeric_limits<long double, true>
385{
386protected:
387 typedef long double type;
388
389 static const bool is_specialized = true;
390
391 static const bool is_signed = true;
392 static const int digits = __LDBL_MANT_DIG__;
393 static const int digits10 = __LDBL_DIG__;
394 static const int max_digits10 = 2+(digits * 30103)/100000;
Howard Hinnanted569212011-05-26 18:23:59 +0000395 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __LDBL_MIN__;}
396 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __LDBL_MAX__;}
397 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000398
399 static const bool is_integer = false;
400 static const bool is_exact = false;
401 static const int radix = __FLT_RADIX__;
Howard Hinnanted569212011-05-26 18:23:59 +0000402 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __LDBL_EPSILON__;}
403 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return 0.5;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000404
405 static const int min_exponent = __LDBL_MIN_EXP__;
406 static const int min_exponent10 = __LDBL_MIN_10_EXP__;
407 static const int max_exponent = __LDBL_MAX_EXP__;
408 static const int max_exponent10 = __LDBL_MAX_10_EXP__;
409
410 static const bool has_infinity = true;
411 static const bool has_quiet_NaN = true;
412 static const bool has_signaling_NaN = true;
413 static const float_denorm_style has_denorm = denorm_present;
414 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000415 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __builtin_huge_vall();}
416 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __builtin_nanl("");}
417 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
418 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000419
420#if (defined(__ppc__) || defined(__ppc64__))
421 static const bool is_iec559 = false;
422#else
423 static const bool is_iec559 = true;
424#endif
425 static const bool is_bounded = true;
426 static const bool is_modulo = false;
427
428 static const bool traps = false;
429 static const bool tinyness_before = false;
430 static const float_round_style round_style = round_to_nearest;
431};
432
433template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000434class _LIBCPP_VISIBLE numeric_limits
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000435 : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
436{
437 typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
438 typedef typename __base::type type;
439public:
440 static const bool is_specialized = __base::is_specialized;
Howard Hinnanted569212011-05-26 18:23:59 +0000441 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __base::min();}
442 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __base::max();}
443 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000444
445 static const int digits = __base::digits;
446 static const int digits10 = __base::digits10;
447 static const int max_digits10 = __base::max_digits10;
448 static const bool is_signed = __base::is_signed;
449 static const bool is_integer = __base::is_integer;
450 static const bool is_exact = __base::is_exact;
451 static const int radix = __base::radix;
Howard Hinnanted569212011-05-26 18:23:59 +0000452 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __base::epsilon();}
453 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000454
455 static const int min_exponent = __base::min_exponent;
456 static const int min_exponent10 = __base::min_exponent10;
457 static const int max_exponent = __base::max_exponent;
458 static const int max_exponent10 = __base::max_exponent10;
459
460 static const bool has_infinity = __base::has_infinity;
461 static const bool has_quiet_NaN = __base::has_quiet_NaN;
462 static const bool has_signaling_NaN = __base::has_signaling_NaN;
463 static const float_denorm_style has_denorm = __base::has_denorm;
464 static const bool has_denorm_loss = __base::has_denorm_loss;
Howard Hinnanted569212011-05-26 18:23:59 +0000465 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __base::infinity();}
466 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
467 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
468 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000469
470 static const bool is_iec559 = __base::is_iec559;
471 static const bool is_bounded = __base::is_bounded;
472 static const bool is_modulo = __base::is_modulo;
473
474 static const bool traps = __base::traps;
475 static const bool tinyness_before = __base::tinyness_before;
476 static const float_round_style round_style = __base::round_style;
477};
478
479template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000480class _LIBCPP_VISIBLE numeric_limits<const _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000481 : private numeric_limits<_Tp>
482{
483 typedef numeric_limits<_Tp> __base;
484 typedef _Tp type;
485public:
486 static const bool is_specialized = __base::is_specialized;
Howard Hinnanted569212011-05-26 18:23:59 +0000487 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __base::min();}
488 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __base::max();}
489 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000490
491 static const int digits = __base::digits;
492 static const int digits10 = __base::digits10;
493 static const int max_digits10 = __base::max_digits10;
494 static const bool is_signed = __base::is_signed;
495 static const bool is_integer = __base::is_integer;
496 static const bool is_exact = __base::is_exact;
497 static const int radix = __base::radix;
Howard Hinnanted569212011-05-26 18:23:59 +0000498 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __base::epsilon();}
499 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000500
501 static const int min_exponent = __base::min_exponent;
502 static const int min_exponent10 = __base::min_exponent10;
503 static const int max_exponent = __base::max_exponent;
504 static const int max_exponent10 = __base::max_exponent10;
505
506 static const bool has_infinity = __base::has_infinity;
507 static const bool has_quiet_NaN = __base::has_quiet_NaN;
508 static const bool has_signaling_NaN = __base::has_signaling_NaN;
509 static const float_denorm_style has_denorm = __base::has_denorm;
510 static const bool has_denorm_loss = __base::has_denorm_loss;
Howard Hinnanted569212011-05-26 18:23:59 +0000511 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __base::infinity();}
512 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
513 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
514 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000515
516 static const bool is_iec559 = __base::is_iec559;
517 static const bool is_bounded = __base::is_bounded;
518 static const bool is_modulo = __base::is_modulo;
519
520 static const bool traps = __base::traps;
521 static const bool tinyness_before = __base::tinyness_before;
522 static const float_round_style round_style = __base::round_style;
523};
524
525template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000526class _LIBCPP_VISIBLE numeric_limits<volatile _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000527 : private numeric_limits<_Tp>
528{
529 typedef numeric_limits<_Tp> __base;
530 typedef _Tp type;
531public:
532 static const bool is_specialized = __base::is_specialized;
Howard Hinnanted569212011-05-26 18:23:59 +0000533 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __base::min();}
534 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __base::max();}
535 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000536
537 static const int digits = __base::digits;
538 static const int digits10 = __base::digits10;
539 static const int max_digits10 = __base::max_digits10;
540 static const bool is_signed = __base::is_signed;
541 static const bool is_integer = __base::is_integer;
542 static const bool is_exact = __base::is_exact;
543 static const int radix = __base::radix;
Howard Hinnanted569212011-05-26 18:23:59 +0000544 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __base::epsilon();}
545 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000546
547 static const int min_exponent = __base::min_exponent;
548 static const int min_exponent10 = __base::min_exponent10;
549 static const int max_exponent = __base::max_exponent;
550 static const int max_exponent10 = __base::max_exponent10;
551
552 static const bool has_infinity = __base::has_infinity;
553 static const bool has_quiet_NaN = __base::has_quiet_NaN;
554 static const bool has_signaling_NaN = __base::has_signaling_NaN;
555 static const float_denorm_style has_denorm = __base::has_denorm;
556 static const bool has_denorm_loss = __base::has_denorm_loss;
Howard Hinnanted569212011-05-26 18:23:59 +0000557 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __base::infinity();}
558 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
559 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
560 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000561
562 static const bool is_iec559 = __base::is_iec559;
563 static const bool is_bounded = __base::is_bounded;
564 static const bool is_modulo = __base::is_modulo;
565
566 static const bool traps = __base::traps;
567 static const bool tinyness_before = __base::tinyness_before;
568 static const float_round_style round_style = __base::round_style;
569};
570
571template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000572class _LIBCPP_VISIBLE numeric_limits<const volatile _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000573 : private numeric_limits<_Tp>
574{
575 typedef numeric_limits<_Tp> __base;
576 typedef _Tp type;
577public:
578 static const bool is_specialized = __base::is_specialized;
Howard Hinnanted569212011-05-26 18:23:59 +0000579 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __base::min();}
580 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __base::max();}
581 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000582
583 static const int digits = __base::digits;
584 static const int digits10 = __base::digits10;
585 static const int max_digits10 = __base::max_digits10;
586 static const bool is_signed = __base::is_signed;
587 static const bool is_integer = __base::is_integer;
588 static const bool is_exact = __base::is_exact;
589 static const int radix = __base::radix;
Howard Hinnanted569212011-05-26 18:23:59 +0000590 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __base::epsilon();}
591 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000592
593 static const int min_exponent = __base::min_exponent;
594 static const int min_exponent10 = __base::min_exponent10;
595 static const int max_exponent = __base::max_exponent;
596 static const int max_exponent10 = __base::max_exponent10;
597
598 static const bool has_infinity = __base::has_infinity;
599 static const bool has_quiet_NaN = __base::has_quiet_NaN;
600 static const bool has_signaling_NaN = __base::has_signaling_NaN;
601 static const float_denorm_style has_denorm = __base::has_denorm;
602 static const bool has_denorm_loss = __base::has_denorm_loss;
Howard Hinnanted569212011-05-26 18:23:59 +0000603 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __base::infinity();}
604 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
605 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
606 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000607
608 static const bool is_iec559 = __base::is_iec559;
609 static const bool is_bounded = __base::is_bounded;
610 static const bool is_modulo = __base::is_modulo;
611
612 static const bool traps = __base::traps;
613 static const bool tinyness_before = __base::tinyness_before;
614 static const float_round_style round_style = __base::round_style;
615};
616
617_LIBCPP_END_NAMESPACE_STD
618
619#endif // _LIBCPP_LIMITS