blob: 5f31c4fdfecfb66a4279ed5b4dbeb667a18f9328 [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
112_LIBCPP_BEGIN_NAMESPACE_STD
113
114enum float_round_style
115{
116 round_indeterminate = -1,
117 round_toward_zero = 0,
118 round_to_nearest = 1,
119 round_toward_infinity = 2,
120 round_toward_neg_infinity = 3
121};
122
123enum float_denorm_style
124{
125 denorm_indeterminate = -1,
126 denorm_absent = 0,
127 denorm_present = 1
128};
129
130template <class _Tp, bool = is_arithmetic<_Tp>::value>
131class __libcpp_numeric_limits
132{
133protected:
134 typedef _Tp type;
135
136 static const bool is_specialized = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000137 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return type();}
138 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return type();}
139 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000140
141 static const int digits = 0;
142 static const int digits10 = 0;
143 static const int max_digits10 = 0;
144 static const bool is_signed = false;
145 static const bool is_integer = false;
146 static const bool is_exact = false;
147 static const int radix = 0;
Howard Hinnanted569212011-05-26 18:23:59 +0000148 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return type();}
149 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000150
151 static const int min_exponent = 0;
152 static const int min_exponent10 = 0;
153 static const int max_exponent = 0;
154 static const int max_exponent10 = 0;
155
156 static const bool has_infinity = false;
157 static const bool has_quiet_NaN = false;
158 static const bool has_signaling_NaN = false;
159 static const float_denorm_style has_denorm = denorm_absent;
160 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000161 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return type();}
162 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return type();}
163 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return type();}
164 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000165
166 static const bool is_iec559 = false;
167 static const bool is_bounded = false;
168 static const bool is_modulo = false;
169
170 static const bool traps = false;
171 static const bool tinyness_before = false;
172 static const float_round_style round_style = round_toward_zero;
173};
174
175template <class _Tp, int digits, bool is_signed>
176struct __libcpp_compute_min
177{
178 static const _Tp value = _Tp(_Tp(1) << digits);
179};
180
181template <class _Tp, int digits>
182struct __libcpp_compute_min<_Tp, digits, false>
183{
184 static const _Tp value = _Tp(0);
185};
186
187template <class _Tp>
188class __libcpp_numeric_limits<_Tp, true>
189{
190protected:
191 typedef _Tp type;
192
193 static const bool is_specialized = true;
194
195 static const bool is_signed = type(-1) < type(0);
196 static const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
197 static const int digits10 = digits * 3 / 10;
198 static const int max_digits10 = 0;
199 static const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
200 static const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
Howard Hinnanted569212011-05-26 18:23:59 +0000201 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __min;}
202 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __max;}
203 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000204
205 static const bool is_integer = true;
206 static const bool is_exact = true;
207 static const int radix = 2;
Howard Hinnanted569212011-05-26 18:23:59 +0000208 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return type(0);}
209 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000210
211 static const int min_exponent = 0;
212 static const int min_exponent10 = 0;
213 static const int max_exponent = 0;
214 static const int max_exponent10 = 0;
215
216 static const bool has_infinity = false;
217 static const bool has_quiet_NaN = false;
218 static const bool has_signaling_NaN = false;
219 static const float_denorm_style has_denorm = denorm_absent;
220 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000221 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return type(0);}
222 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return type(0);}
223 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return type(0);}
224 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000225
226 static const bool is_iec559 = false;
227 static const bool is_bounded = true;
228 static const bool is_modulo = true;
229
230#if __i386__ || __x86_64__
231 static const bool traps = true;
232#else
233 static const bool traps = false;
234#endif
235 static const bool tinyness_before = false;
236 static const float_round_style round_style = round_toward_zero;
237};
238
239template <>
240class __libcpp_numeric_limits<bool, true>
241{
242protected:
243 typedef bool type;
244
245 static const bool is_specialized = true;
246
247 static const bool is_signed = false;
248 static const int digits = 1;
249 static const int digits10 = 0;
250 static const int max_digits10 = 0;
251 static const type __min = false;
252 static const type __max = true;
Howard Hinnanted569212011-05-26 18:23:59 +0000253 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __min;}
254 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __max;}
255 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000256
257 static const bool is_integer = true;
258 static const bool is_exact = true;
259 static const int radix = 2;
Howard Hinnanted569212011-05-26 18:23:59 +0000260 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return type(0);}
261 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000262
263 static const int min_exponent = 0;
264 static const int min_exponent10 = 0;
265 static const int max_exponent = 0;
266 static const int max_exponent10 = 0;
267
268 static const bool has_infinity = false;
269 static const bool has_quiet_NaN = false;
270 static const bool has_signaling_NaN = false;
271 static const float_denorm_style has_denorm = denorm_absent;
272 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000273 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return type(0);}
274 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return type(0);}
275 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return type(0);}
276 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000277
278 static const bool is_iec559 = false;
279 static const bool is_bounded = true;
280 static const bool is_modulo = false;
281
282 static const bool traps = false;
283 static const bool tinyness_before = false;
284 static const float_round_style round_style = round_toward_zero;
285};
286
287template <>
288class __libcpp_numeric_limits<float, true>
289{
290protected:
291 typedef float type;
292
293 static const bool is_specialized = true;
294
295 static const bool is_signed = true;
296 static const int digits = __FLT_MANT_DIG__;
297 static const int digits10 = __FLT_DIG__;
298 static const int max_digits10 = 2+(digits * 30103)/100000;
Howard Hinnanted569212011-05-26 18:23:59 +0000299 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __FLT_MIN__;}
300 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __FLT_MAX__;}
301 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000302
303 static const bool is_integer = false;
304 static const bool is_exact = false;
305 static const int radix = __FLT_RADIX__;
Howard Hinnanted569212011-05-26 18:23:59 +0000306 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __FLT_EPSILON__;}
307 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return 0.5F;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000308
309 static const int min_exponent = __FLT_MIN_EXP__;
310 static const int min_exponent10 = __FLT_MIN_10_EXP__;
311 static const int max_exponent = __FLT_MAX_EXP__;
312 static const int max_exponent10 = __FLT_MAX_10_EXP__;
313
314 static const bool has_infinity = true;
315 static const bool has_quiet_NaN = true;
316 static const bool has_signaling_NaN = true;
317 static const float_denorm_style has_denorm = denorm_present;
318 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000319 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __builtin_huge_valf();}
320 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __builtin_nanf("");}
321 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __builtin_nansf("");}
322 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __FLT_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000323
324 static const bool is_iec559 = true;
325 static const bool is_bounded = true;
326 static const bool is_modulo = false;
327
328 static const bool traps = false;
329 static const bool tinyness_before = false;
330 static const float_round_style round_style = round_to_nearest;
331};
332
333template <>
334class __libcpp_numeric_limits<double, true>
335{
336protected:
337 typedef double type;
338
339 static const bool is_specialized = true;
340
341 static const bool is_signed = true;
342 static const int digits = __DBL_MANT_DIG__;
343 static const int digits10 = __DBL_DIG__;
344 static const int max_digits10 = 2+(digits * 30103)/100000;
Howard Hinnanted569212011-05-26 18:23:59 +0000345 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __DBL_MIN__;}
346 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __DBL_MAX__;}
347 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000348
349 static const bool is_integer = false;
350 static const bool is_exact = false;
351 static const int radix = __FLT_RADIX__;
Howard Hinnanted569212011-05-26 18:23:59 +0000352 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __DBL_EPSILON__;}
353 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return 0.5;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000354
355 static const int min_exponent = __DBL_MIN_EXP__;
356 static const int min_exponent10 = __DBL_MIN_10_EXP__;
357 static const int max_exponent = __DBL_MAX_EXP__;
358 static const int max_exponent10 = __DBL_MAX_10_EXP__;
359
360 static const bool has_infinity = true;
361 static const bool has_quiet_NaN = true;
362 static const bool has_signaling_NaN = true;
363 static const float_denorm_style has_denorm = denorm_present;
364 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000365 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __builtin_huge_val();}
366 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __builtin_nan("");}
367 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __builtin_nans("");}
368 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __DBL_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000369
370 static const bool is_iec559 = true;
371 static const bool is_bounded = true;
372 static const bool is_modulo = false;
373
374 static const bool traps = false;
375 static const bool tinyness_before = false;
376 static const float_round_style round_style = round_to_nearest;
377};
378
379template <>
380class __libcpp_numeric_limits<long double, true>
381{
382protected:
383 typedef long double type;
384
385 static const bool is_specialized = true;
386
387 static const bool is_signed = true;
388 static const int digits = __LDBL_MANT_DIG__;
389 static const int digits10 = __LDBL_DIG__;
390 static const int max_digits10 = 2+(digits * 30103)/100000;
Howard Hinnanted569212011-05-26 18:23:59 +0000391 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __LDBL_MIN__;}
392 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __LDBL_MAX__;}
393 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000394
395 static const bool is_integer = false;
396 static const bool is_exact = false;
397 static const int radix = __FLT_RADIX__;
Howard Hinnanted569212011-05-26 18:23:59 +0000398 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __LDBL_EPSILON__;}
399 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return 0.5;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000400
401 static const int min_exponent = __LDBL_MIN_EXP__;
402 static const int min_exponent10 = __LDBL_MIN_10_EXP__;
403 static const int max_exponent = __LDBL_MAX_EXP__;
404 static const int max_exponent10 = __LDBL_MAX_10_EXP__;
405
406 static const bool has_infinity = true;
407 static const bool has_quiet_NaN = true;
408 static const bool has_signaling_NaN = true;
409 static const float_denorm_style has_denorm = denorm_present;
410 static const bool has_denorm_loss = false;
Howard Hinnanted569212011-05-26 18:23:59 +0000411 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __builtin_huge_vall();}
412 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __builtin_nanl("");}
413 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
414 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000415
416#if (defined(__ppc__) || defined(__ppc64__))
417 static const bool is_iec559 = false;
418#else
419 static const bool is_iec559 = true;
420#endif
421 static const bool is_bounded = true;
422 static const bool is_modulo = false;
423
424 static const bool traps = false;
425 static const bool tinyness_before = false;
426 static const float_round_style round_style = round_to_nearest;
427};
428
429template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000430class _LIBCPP_VISIBLE numeric_limits
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000431 : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
432{
433 typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
434 typedef typename __base::type type;
435public:
436 static const bool is_specialized = __base::is_specialized;
Howard Hinnanted569212011-05-26 18:23:59 +0000437 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __base::min();}
438 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __base::max();}
439 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000440
441 static const int digits = __base::digits;
442 static const int digits10 = __base::digits10;
443 static const int max_digits10 = __base::max_digits10;
444 static const bool is_signed = __base::is_signed;
445 static const bool is_integer = __base::is_integer;
446 static const bool is_exact = __base::is_exact;
447 static const int radix = __base::radix;
Howard Hinnanted569212011-05-26 18:23:59 +0000448 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __base::epsilon();}
449 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000450
451 static const int min_exponent = __base::min_exponent;
452 static const int min_exponent10 = __base::min_exponent10;
453 static const int max_exponent = __base::max_exponent;
454 static const int max_exponent10 = __base::max_exponent10;
455
456 static const bool has_infinity = __base::has_infinity;
457 static const bool has_quiet_NaN = __base::has_quiet_NaN;
458 static const bool has_signaling_NaN = __base::has_signaling_NaN;
459 static const float_denorm_style has_denorm = __base::has_denorm;
460 static const bool has_denorm_loss = __base::has_denorm_loss;
Howard Hinnanted569212011-05-26 18:23:59 +0000461 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __base::infinity();}
462 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
463 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
464 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000465
466 static const bool is_iec559 = __base::is_iec559;
467 static const bool is_bounded = __base::is_bounded;
468 static const bool is_modulo = __base::is_modulo;
469
470 static const bool traps = __base::traps;
471 static const bool tinyness_before = __base::tinyness_before;
472 static const float_round_style round_style = __base::round_style;
473};
474
475template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000476class _LIBCPP_VISIBLE numeric_limits<const _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000477 : private numeric_limits<_Tp>
478{
479 typedef numeric_limits<_Tp> __base;
480 typedef _Tp type;
481public:
482 static const bool is_specialized = __base::is_specialized;
Howard Hinnanted569212011-05-26 18:23:59 +0000483 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __base::min();}
484 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __base::max();}
485 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000486
487 static const int digits = __base::digits;
488 static const int digits10 = __base::digits10;
489 static const int max_digits10 = __base::max_digits10;
490 static const bool is_signed = __base::is_signed;
491 static const bool is_integer = __base::is_integer;
492 static const bool is_exact = __base::is_exact;
493 static const int radix = __base::radix;
Howard Hinnanted569212011-05-26 18:23:59 +0000494 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __base::epsilon();}
495 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000496
497 static const int min_exponent = __base::min_exponent;
498 static const int min_exponent10 = __base::min_exponent10;
499 static const int max_exponent = __base::max_exponent;
500 static const int max_exponent10 = __base::max_exponent10;
501
502 static const bool has_infinity = __base::has_infinity;
503 static const bool has_quiet_NaN = __base::has_quiet_NaN;
504 static const bool has_signaling_NaN = __base::has_signaling_NaN;
505 static const float_denorm_style has_denorm = __base::has_denorm;
506 static const bool has_denorm_loss = __base::has_denorm_loss;
Howard Hinnanted569212011-05-26 18:23:59 +0000507 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __base::infinity();}
508 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
509 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
510 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000511
512 static const bool is_iec559 = __base::is_iec559;
513 static const bool is_bounded = __base::is_bounded;
514 static const bool is_modulo = __base::is_modulo;
515
516 static const bool traps = __base::traps;
517 static const bool tinyness_before = __base::tinyness_before;
518 static const float_round_style round_style = __base::round_style;
519};
520
521template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000522class _LIBCPP_VISIBLE numeric_limits<volatile _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000523 : private numeric_limits<_Tp>
524{
525 typedef numeric_limits<_Tp> __base;
526 typedef _Tp type;
527public:
528 static const bool is_specialized = __base::is_specialized;
Howard Hinnanted569212011-05-26 18:23:59 +0000529 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __base::min();}
530 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __base::max();}
531 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000532
533 static const int digits = __base::digits;
534 static const int digits10 = __base::digits10;
535 static const int max_digits10 = __base::max_digits10;
536 static const bool is_signed = __base::is_signed;
537 static const bool is_integer = __base::is_integer;
538 static const bool is_exact = __base::is_exact;
539 static const int radix = __base::radix;
Howard Hinnanted569212011-05-26 18:23:59 +0000540 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __base::epsilon();}
541 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000542
543 static const int min_exponent = __base::min_exponent;
544 static const int min_exponent10 = __base::min_exponent10;
545 static const int max_exponent = __base::max_exponent;
546 static const int max_exponent10 = __base::max_exponent10;
547
548 static const bool has_infinity = __base::has_infinity;
549 static const bool has_quiet_NaN = __base::has_quiet_NaN;
550 static const bool has_signaling_NaN = __base::has_signaling_NaN;
551 static const float_denorm_style has_denorm = __base::has_denorm;
552 static const bool has_denorm_loss = __base::has_denorm_loss;
Howard Hinnanted569212011-05-26 18:23:59 +0000553 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __base::infinity();}
554 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
555 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
556 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000557
558 static const bool is_iec559 = __base::is_iec559;
559 static const bool is_bounded = __base::is_bounded;
560 static const bool is_modulo = __base::is_modulo;
561
562 static const bool traps = __base::traps;
563 static const bool tinyness_before = __base::tinyness_before;
564 static const float_round_style round_style = __base::round_style;
565};
566
567template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000568class _LIBCPP_VISIBLE numeric_limits<const volatile _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000569 : private numeric_limits<_Tp>
570{
571 typedef numeric_limits<_Tp> __base;
572 typedef _Tp type;
573public:
574 static const bool is_specialized = __base::is_specialized;
Howard Hinnanted569212011-05-26 18:23:59 +0000575 _LIBCPP_INLINE_VISIBILITY static type min() _NOEXCEPT {return __base::min();}
576 _LIBCPP_INLINE_VISIBILITY static type max() _NOEXCEPT {return __base::max();}
577 _LIBCPP_INLINE_VISIBILITY static type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000578
579 static const int digits = __base::digits;
580 static const int digits10 = __base::digits10;
581 static const int max_digits10 = __base::max_digits10;
582 static const bool is_signed = __base::is_signed;
583 static const bool is_integer = __base::is_integer;
584 static const bool is_exact = __base::is_exact;
585 static const int radix = __base::radix;
Howard Hinnanted569212011-05-26 18:23:59 +0000586 _LIBCPP_INLINE_VISIBILITY static type epsilon() _NOEXCEPT {return __base::epsilon();}
587 _LIBCPP_INLINE_VISIBILITY static type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000588
589 static const int min_exponent = __base::min_exponent;
590 static const int min_exponent10 = __base::min_exponent10;
591 static const int max_exponent = __base::max_exponent;
592 static const int max_exponent10 = __base::max_exponent10;
593
594 static const bool has_infinity = __base::has_infinity;
595 static const bool has_quiet_NaN = __base::has_quiet_NaN;
596 static const bool has_signaling_NaN = __base::has_signaling_NaN;
597 static const float_denorm_style has_denorm = __base::has_denorm;
598 static const bool has_denorm_loss = __base::has_denorm_loss;
Howard Hinnanted569212011-05-26 18:23:59 +0000599 _LIBCPP_INLINE_VISIBILITY static type infinity() _NOEXCEPT {return __base::infinity();}
600 _LIBCPP_INLINE_VISIBILITY static type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
601 _LIBCPP_INLINE_VISIBILITY static type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
602 _LIBCPP_INLINE_VISIBILITY static type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000603
604 static const bool is_iec559 = __base::is_iec559;
605 static const bool is_bounded = __base::is_bounded;
606 static const bool is_modulo = __base::is_modulo;
607
608 static const bool traps = __base::traps;
609 static const bool tinyness_before = __base::tinyness_before;
610 static const float_round_style round_style = __base::round_style;
611};
612
613_LIBCPP_END_NAMESPACE_STD
614
615#endif // _LIBCPP_LIMITS