blob: f089a794dc1efd4c911d1653438d89f8080e2992 [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:
Howard Hinnant60cb7d22012-04-02 19:23:15 +000024 static constexpr bool is_specialized = false;
25 static constexpr T min() noexcept;
26 static constexpr T max() noexcept;
27 static constexpr T lowest() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000028
Howard Hinnant60cb7d22012-04-02 19:23:15 +000029 static constexpr int digits = 0;
30 static constexpr int digits10 = 0;
31 static constexpr int max_digits10 = 0;
32 static constexpr bool is_signed = false;
33 static constexpr bool is_integer = false;
34 static constexpr bool is_exact = false;
35 static constexpr int radix = 0;
36 static constexpr T epsilon() noexcept;
37 static constexpr T round_error() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000038
Howard Hinnant60cb7d22012-04-02 19:23:15 +000039 static constexpr int min_exponent = 0;
40 static constexpr int min_exponent10 = 0;
41 static constexpr int max_exponent = 0;
42 static constexpr int max_exponent10 = 0;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000043
Howard Hinnant60cb7d22012-04-02 19:23:15 +000044 static constexpr bool has_infinity = false;
45 static constexpr bool has_quiet_NaN = false;
46 static constexpr bool has_signaling_NaN = false;
47 static constexpr float_denorm_style has_denorm = denorm_absent;
48 static constexpr bool has_denorm_loss = false;
49 static constexpr T infinity() noexcept;
50 static constexpr T quiet_NaN() noexcept;
51 static constexpr T signaling_NaN() noexcept;
52 static constexpr T denorm_min() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000053
Howard Hinnant60cb7d22012-04-02 19:23:15 +000054 static constexpr bool is_iec559 = false;
55 static constexpr bool is_bounded = false;
56 static constexpr bool is_modulo = false;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000057
Howard Hinnant60cb7d22012-04-02 19:23:15 +000058 static constexpr bool traps = false;
59 static constexpr bool tinyness_before = false;
60 static constexpr float_round_style round_style = round_toward_zero;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000061};
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 Hinnant66c6f972011-11-29 16:45:27 +0000112#include <__undef_min_max>
113
Howard Hinnant78b68282011-10-22 20:59:45 +0000114#if defined(_MSC_VER)
115#include "support/win32/limits_win32.h"
116#endif // _MSC_VER
117
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000118_LIBCPP_BEGIN_NAMESPACE_STD
119
120enum float_round_style
121{
122 round_indeterminate = -1,
123 round_toward_zero = 0,
124 round_to_nearest = 1,
125 round_toward_infinity = 2,
126 round_toward_neg_infinity = 3
127};
128
129enum float_denorm_style
130{
131 denorm_indeterminate = -1,
132 denorm_absent = 0,
133 denorm_present = 1
134};
135
136template <class _Tp, bool = is_arithmetic<_Tp>::value>
137class __libcpp_numeric_limits
138{
139protected:
140 typedef _Tp type;
141
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000142 static _LIBCPP_CONSTEXPR const bool is_specialized = false;
143 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return type();}
144 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return type();}
145 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000146
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000147 static _LIBCPP_CONSTEXPR const int digits = 0;
148 static _LIBCPP_CONSTEXPR const int digits10 = 0;
149 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
150 static _LIBCPP_CONSTEXPR const bool is_signed = false;
151 static _LIBCPP_CONSTEXPR const bool is_integer = false;
152 static _LIBCPP_CONSTEXPR const bool is_exact = false;
153 static _LIBCPP_CONSTEXPR const int radix = 0;
154 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type();}
155 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000156
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000157 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
158 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
159 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
160 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000161
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000162 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
163 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
164 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
165 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
166 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
167 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type();}
168 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type();}
169 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type();}
170 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000171
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000172 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
173 static _LIBCPP_CONSTEXPR const bool is_bounded = false;
174 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000175
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000176 static _LIBCPP_CONSTEXPR const bool traps = false;
177 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
178 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000179};
180
181template <class _Tp, int digits, bool is_signed>
182struct __libcpp_compute_min
183{
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000184 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << digits);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000185};
186
187template <class _Tp, int digits>
188struct __libcpp_compute_min<_Tp, digits, false>
189{
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000190 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000191};
192
193template <class _Tp>
194class __libcpp_numeric_limits<_Tp, true>
195{
196protected:
197 typedef _Tp type;
198
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000199 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000200
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000201 static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);
202 static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
203 static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;
204 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
205 static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
206 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
207 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __min;}
208 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __max;}
209 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000210
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000211 static _LIBCPP_CONSTEXPR const bool is_integer = true;
212 static _LIBCPP_CONSTEXPR const bool is_exact = true;
213 static _LIBCPP_CONSTEXPR const int radix = 2;
214 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type(0);}
215 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000216
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000217 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
218 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
219 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
220 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000221
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000222 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
223 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
224 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
225 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
226 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
227 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);}
228 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);}
229 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);}
230 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000231
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000232 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
233 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
234 static _LIBCPP_CONSTEXPR const bool is_modulo = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000235
236#if __i386__ || __x86_64__
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000237 static _LIBCPP_CONSTEXPR const bool traps = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000238#else
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000239 static _LIBCPP_CONSTEXPR const bool traps = false;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000240#endif
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000241 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
242 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000243};
244
245template <>
246class __libcpp_numeric_limits<bool, true>
247{
248protected:
249 typedef bool type;
250
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000251 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000252
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000253 static _LIBCPP_CONSTEXPR const bool is_signed = false;
254 static _LIBCPP_CONSTEXPR const int digits = 1;
255 static _LIBCPP_CONSTEXPR const int digits10 = 0;
256 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
257 static _LIBCPP_CONSTEXPR const type __min = false;
258 static _LIBCPP_CONSTEXPR const type __max = true;
259 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __min;}
260 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __max;}
261 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000262
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000263 static _LIBCPP_CONSTEXPR const bool is_integer = true;
264 static _LIBCPP_CONSTEXPR const bool is_exact = true;
265 static _LIBCPP_CONSTEXPR const int radix = 2;
266 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type(0);}
267 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000268
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000269 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
270 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
271 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
272 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000273
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000274 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
275 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
276 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
277 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
278 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
279 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);}
280 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);}
281 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);}
282 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000283
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000284 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
285 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
286 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000287
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000288 static _LIBCPP_CONSTEXPR const bool traps = false;
289 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
290 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000291};
292
293template <>
294class __libcpp_numeric_limits<float, true>
295{
296protected:
297 typedef float type;
298
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000299 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000300
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000301 static _LIBCPP_CONSTEXPR const bool is_signed = true;
302 static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;
303 static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;
304 static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103)/100000;
305 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __FLT_MIN__;}
306 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __FLT_MAX__;}
307 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000308
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000309 static _LIBCPP_CONSTEXPR const bool is_integer = false;
310 static _LIBCPP_CONSTEXPR const bool is_exact = false;
311 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
312 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __FLT_EPSILON__;}
313 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5F;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000314
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000315 static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;
316 static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;
317 static _LIBCPP_CONSTEXPR const int max_exponent = __FLT_MAX_EXP__;
318 static _LIBCPP_CONSTEXPR const int max_exponent10 = __FLT_MAX_10_EXP__;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000319
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000320 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
321 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
322 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
323 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
324 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
325 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_valf();}
326 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanf("");}
327 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansf("");}
328 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __FLT_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000329
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000330 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
331 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
332 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000333
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000334 static _LIBCPP_CONSTEXPR const bool traps = false;
335 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
336 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000337};
338
339template <>
340class __libcpp_numeric_limits<double, true>
341{
342protected:
343 typedef double type;
344
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000345 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000346
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000347 static _LIBCPP_CONSTEXPR const bool is_signed = true;
348 static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;
349 static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;
350 static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103)/100000;
351 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __DBL_MIN__;}
352 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __DBL_MAX__;}
353 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000354
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000355 static _LIBCPP_CONSTEXPR const bool is_integer = false;
356 static _LIBCPP_CONSTEXPR const bool is_exact = false;
357 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
358 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __DBL_EPSILON__;}
359 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000360
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000361 static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;
362 static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;
363 static _LIBCPP_CONSTEXPR const int max_exponent = __DBL_MAX_EXP__;
364 static _LIBCPP_CONSTEXPR const int max_exponent10 = __DBL_MAX_10_EXP__;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000365
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000366 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
367 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
368 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
369 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
370 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
371 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_val();}
372 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nan("");}
373 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nans("");}
374 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __DBL_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000375
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000376 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
377 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
378 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000379
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000380 static _LIBCPP_CONSTEXPR const bool traps = false;
381 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
382 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000383};
384
385template <>
386class __libcpp_numeric_limits<long double, true>
387{
388protected:
389 typedef long double type;
390
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000391 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000392
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000393 static _LIBCPP_CONSTEXPR const bool is_signed = true;
394 static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;
395 static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;
396 static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103)/100000;
397 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __LDBL_MIN__;}
398 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __LDBL_MAX__;}
399 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000400
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000401 static _LIBCPP_CONSTEXPR const bool is_integer = false;
402 static _LIBCPP_CONSTEXPR const bool is_exact = false;
403 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
404 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __LDBL_EPSILON__;}
405 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000406
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000407 static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;
408 static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;
409 static _LIBCPP_CONSTEXPR const int max_exponent = __LDBL_MAX_EXP__;
410 static _LIBCPP_CONSTEXPR const int max_exponent10 = __LDBL_MAX_10_EXP__;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000411
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000412 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
413 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
414 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
415 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
416 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
417 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_vall();}
418 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanl("");}
419 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
420 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000421
422#if (defined(__ppc__) || defined(__ppc64__))
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000423 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000424#else
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000425 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000426#endif
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000427 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
428 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000429
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000430 static _LIBCPP_CONSTEXPR const bool traps = false;
431 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
432 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000433};
434
435template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000436class _LIBCPP_VISIBLE numeric_limits
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000437 : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
438{
439 typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
440 typedef typename __base::type type;
441public:
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000442 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
443 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
444 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
445 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000446
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000447 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
448 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
449 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
450 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
451 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
452 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
453 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
454 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
455 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000456
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000457 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
458 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
459 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
460 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000461
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000462 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
463 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
464 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
465 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
466 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
467 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
468 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
469 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
470 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000471
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000472 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
473 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
474 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000475
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000476 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
477 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
478 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000479};
480
481template <class _Tp>
Howard Hinnant0a69fa12012-12-12 21:14:28 +0000482 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;
483template <class _Tp>
484 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;
485template <class _Tp>
486 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;
487template <class _Tp>
488 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;
489template <class _Tp>
490 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;
491template <class _Tp>
492 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;
493template <class _Tp>
494 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;
495template <class _Tp>
496 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;
497template <class _Tp>
498 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;
499template <class _Tp>
500 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;
501template <class _Tp>
502 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;
503template <class _Tp>
504 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;
505template <class _Tp>
506 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;
507template <class _Tp>
508 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;
509template <class _Tp>
510 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;
511template <class _Tp>
512 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;
513template <class _Tp>
514 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;
515template <class _Tp>
516 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;
517template <class _Tp>
518 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;
519template <class _Tp>
520 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;
521template <class _Tp>
522 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;
523template <class _Tp>
524 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;
525template <class _Tp>
526 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
527
528template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000529class _LIBCPP_VISIBLE numeric_limits<const _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000530 : private numeric_limits<_Tp>
531{
532 typedef numeric_limits<_Tp> __base;
533 typedef _Tp type;
534public:
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000535 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
536 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
537 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
538 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000539
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000540 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
541 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
542 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
543 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
544 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
545 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
546 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
547 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
548 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000549
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000550 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
551 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
552 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
553 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000554
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000555 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
556 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
557 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
558 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
559 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
560 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
561 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
562 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
563 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000564
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000565 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
566 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
567 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000568
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000569 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
570 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
571 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000572};
573
574template <class _Tp>
Howard Hinnant0a69fa12012-12-12 21:14:28 +0000575 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_specialized;
576template <class _Tp>
577 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits;
578template <class _Tp>
579 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits10;
580template <class _Tp>
581 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_digits10;
582template <class _Tp>
583 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_signed;
584template <class _Tp>
585 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_integer;
586template <class _Tp>
587 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_exact;
588template <class _Tp>
589 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::radix;
590template <class _Tp>
591 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent;
592template <class _Tp>
593 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent10;
594template <class _Tp>
595 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent;
596template <class _Tp>
597 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent10;
598template <class _Tp>
599 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_infinity;
600template <class _Tp>
601 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_quiet_NaN;
602template <class _Tp>
603 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_signaling_NaN;
604template <class _Tp>
605 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const _Tp>::has_denorm;
606template <class _Tp>
607 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_denorm_loss;
608template <class _Tp>
609 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_iec559;
610template <class _Tp>
611 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_bounded;
612template <class _Tp>
613 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_modulo;
614template <class _Tp>
615 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::traps;
616template <class _Tp>
617 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::tinyness_before;
618template <class _Tp>
619 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style;
620
621template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000622class _LIBCPP_VISIBLE numeric_limits<volatile _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000623 : private numeric_limits<_Tp>
624{
625 typedef numeric_limits<_Tp> __base;
626 typedef _Tp type;
627public:
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000628 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
629 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
630 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
631 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000632
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000633 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
634 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
635 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
636 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
637 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
638 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
639 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
640 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
641 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000642
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000643 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
644 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
645 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
646 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000647
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000648 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
649 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
650 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
651 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
652 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
653 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
654 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
655 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
656 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000657
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000658 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
659 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
660 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000661
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000662 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
663 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
664 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000665};
666
667template <class _Tp>
Howard Hinnant0a69fa12012-12-12 21:14:28 +0000668 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_specialized;
669template <class _Tp>
670 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits;
671template <class _Tp>
672 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits10;
673template <class _Tp>
674 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_digits10;
675template <class _Tp>
676 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_signed;
677template <class _Tp>
678 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_integer;
679template <class _Tp>
680 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_exact;
681template <class _Tp>
682 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::radix;
683template <class _Tp>
684 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent;
685template <class _Tp>
686 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent10;
687template <class _Tp>
688 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent;
689template <class _Tp>
690 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent10;
691template <class _Tp>
692 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_infinity;
693template <class _Tp>
694 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_quiet_NaN;
695template <class _Tp>
696 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_signaling_NaN;
697template <class _Tp>
698 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<volatile _Tp>::has_denorm;
699template <class _Tp>
700 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_denorm_loss;
701template <class _Tp>
702 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_iec559;
703template <class _Tp>
704 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_bounded;
705template <class _Tp>
706 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_modulo;
707template <class _Tp>
708 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::traps;
709template <class _Tp>
710 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::tinyness_before;
711template <class _Tp>
712 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style;
713
714template <class _Tp>
Howard Hinnant82894812010-09-22 16:48:34 +0000715class _LIBCPP_VISIBLE numeric_limits<const volatile _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000716 : private numeric_limits<_Tp>
717{
718 typedef numeric_limits<_Tp> __base;
719 typedef _Tp type;
720public:
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000721 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
722 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
723 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
724 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000725
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000726 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
727 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
728 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
729 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
730 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
731 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
732 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
733 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
734 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000735
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000736 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
737 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
738 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
739 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000740
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000741 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
742 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
743 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
744 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
745 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
746 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
747 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
748 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
749 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000750
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000751 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
752 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
753 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000754
Howard Hinnant60cb7d22012-04-02 19:23:15 +0000755 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
756 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
757 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000758};
759
Howard Hinnant0a69fa12012-12-12 21:14:28 +0000760template <class _Tp>
761 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_specialized;
762template <class _Tp>
763 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits;
764template <class _Tp>
765 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits10;
766template <class _Tp>
767 const int numeric_limits<const volatile _Tp>::max_digits10;
768template <class _Tp>
769 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_signed;
770template <class _Tp>
771 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_integer;
772template <class _Tp>
773 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_exact;
774template <class _Tp>
775 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::radix;
776template <class _Tp>
777 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent;
778template <class _Tp>
779 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent10;
780template <class _Tp>
781 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent;
782template <class _Tp>
783 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent10;
784template <class _Tp>
785 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_infinity;
786template <class _Tp>
787 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_quiet_NaN;
788template <class _Tp>
789 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_signaling_NaN;
790template <class _Tp>
791 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const volatile _Tp>::has_denorm;
792template <class _Tp>
793 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_denorm_loss;
794template <class _Tp>
795 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_iec559;
796template <class _Tp>
797 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_bounded;
798template <class _Tp>
799 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_modulo;
800template <class _Tp>
801 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::traps;
802template <class _Tp>
803 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::tinyness_before;
804template <class _Tp>
805 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const volatile _Tp>::round_style;
806
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000807_LIBCPP_END_NAMESPACE_STD
808
809#endif // _LIBCPP_LIMITS