blob: f530507f72464a854903e24107fd32670dfd98b5 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- limits ----------------------------------===//
3//
Howard Hinnantc566dc32010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantc51e1022010-05-11 19:42:16 +00005//
Howard Hinnantee11c312010-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 Hinnantc51e1022010-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 Hinnant50ed0b22012-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 Hinnantc51e1022010-05-11 19:42:16 +000028
Howard Hinnant50ed0b22012-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 Hinnantc51e1022010-05-11 19:42:16 +000038
Howard Hinnant50ed0b22012-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 Hinnantc51e1022010-05-11 19:42:16 +000043
Howard Hinnant50ed0b22012-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 Hinnantc51e1022010-05-11 19:42:16 +000053
Howard Hinnant50ed0b22012-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 Hinnantc51e1022010-05-11 19:42:16 +000057
Howard Hinnant50ed0b22012-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 Hinnantc51e1022010-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*/
Ben Craig092e2632017-04-11 14:06:39 +0000104#include <__config>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000105#include <type_traits>
106
Eric Fiselier4a984f02017-05-10 20:57:45 +0000107#if defined(_LIBCPP_COMPILER_MSVC)
108#include "support/win32/limits_msvc_win32.h"
Howard Hinnant13d8bc12013-08-01 18:17:34 +0000109#endif // _LIBCPP_MSVCRT
Howard Hinnantbf074022011-10-22 20:59:45 +0000110
Howard Hinnantea382952013-08-14 18:00:20 +0000111#if defined(__IBMCPP__)
112#include "support/ibm/limits.h"
113#endif // __IBMCPP__
114
Eric Fiselierf4433a32017-05-31 22:07:49 +0000115#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
116#pragma GCC system_header
117#endif
118
119_LIBCPP_PUSH_MACROS
120#include <__undef_macros>
121
122
Howard Hinnantc51e1022010-05-11 19:42:16 +0000123_LIBCPP_BEGIN_NAMESPACE_STD
124
125enum float_round_style
126{
127 round_indeterminate = -1,
128 round_toward_zero = 0,
129 round_to_nearest = 1,
130 round_toward_infinity = 2,
131 round_toward_neg_infinity = 3
132};
133
134enum float_denorm_style
135{
136 denorm_indeterminate = -1,
137 denorm_absent = 0,
138 denorm_present = 1
139};
140
141template <class _Tp, bool = is_arithmetic<_Tp>::value>
142class __libcpp_numeric_limits
143{
144protected:
145 typedef _Tp type;
146
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000147 static _LIBCPP_CONSTEXPR const bool is_specialized = false;
148 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return type();}
149 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return type();}
150 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return type();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000151
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000152 static _LIBCPP_CONSTEXPR const int digits = 0;
153 static _LIBCPP_CONSTEXPR const int digits10 = 0;
154 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
155 static _LIBCPP_CONSTEXPR const bool is_signed = false;
156 static _LIBCPP_CONSTEXPR const bool is_integer = false;
157 static _LIBCPP_CONSTEXPR const bool is_exact = false;
158 static _LIBCPP_CONSTEXPR const int radix = 0;
159 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type();}
160 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000161
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000162 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
163 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
164 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
165 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000166
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000167 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
168 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
169 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
170 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
171 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
172 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type();}
173 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type();}
174 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type();}
175 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000176
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000177 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
178 static _LIBCPP_CONSTEXPR const bool is_bounded = false;
179 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000180
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000181 static _LIBCPP_CONSTEXPR const bool traps = false;
182 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
183 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000184};
185
Eric Fiselierc5ea1ae2017-06-01 02:29:37 +0000186template <class _Tp, int __digits, bool _IsSigned>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000187struct __libcpp_compute_min
188{
Eric Fiselierc5ea1ae2017-06-01 02:29:37 +0000189 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000190};
191
Eric Fiselierc5ea1ae2017-06-01 02:29:37 +0000192template <class _Tp, int __digits>
193struct __libcpp_compute_min<_Tp, __digits, false>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000194{
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000195 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000196};
197
198template <class _Tp>
199class __libcpp_numeric_limits<_Tp, true>
200{
201protected:
202 typedef _Tp type;
203
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000204 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000205
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000206 static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);
207 static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
208 static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;
209 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
210 static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
211 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
212 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __min;}
213 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __max;}
214 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return min();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000215
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000216 static _LIBCPP_CONSTEXPR const bool is_integer = true;
217 static _LIBCPP_CONSTEXPR const bool is_exact = true;
218 static _LIBCPP_CONSTEXPR const int radix = 2;
219 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type(0);}
220 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type(0);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000221
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000222 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
223 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
224 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
225 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000226
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000227 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
228 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
229 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
230 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
231 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
232 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);}
233 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);}
234 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);}
235 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type(0);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000236
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000237 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
238 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
Marshall Clowe7d8cce2014-07-31 01:18:05 +0000239 static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000240
Dan Gohman33325ae2016-01-13 16:32:00 +0000241#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
242 defined(__wasm__)
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000243 static _LIBCPP_CONSTEXPR const bool traps = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000244#else
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000245 static _LIBCPP_CONSTEXPR const bool traps = false;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000246#endif
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000247 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
248 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000249};
250
251template <>
252class __libcpp_numeric_limits<bool, true>
253{
254protected:
255 typedef bool type;
256
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000257 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000258
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000259 static _LIBCPP_CONSTEXPR const bool is_signed = false;
260 static _LIBCPP_CONSTEXPR const int digits = 1;
261 static _LIBCPP_CONSTEXPR const int digits10 = 0;
262 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
263 static _LIBCPP_CONSTEXPR const type __min = false;
264 static _LIBCPP_CONSTEXPR const type __max = true;
265 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __min;}
266 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __max;}
267 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return min();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000268
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000269 static _LIBCPP_CONSTEXPR const bool is_integer = true;
270 static _LIBCPP_CONSTEXPR const bool is_exact = true;
271 static _LIBCPP_CONSTEXPR const int radix = 2;
272 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type(0);}
273 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type(0);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000274
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000275 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
276 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
277 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
278 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000279
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000280 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
281 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
282 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
283 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
284 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
285 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);}
286 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);}
287 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);}
288 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type(0);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000289
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000290 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
291 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
292 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000293
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000294 static _LIBCPP_CONSTEXPR const bool traps = false;
295 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
296 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000297};
298
299template <>
300class __libcpp_numeric_limits<float, true>
301{
302protected:
303 typedef float type;
304
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000305 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000306
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000307 static _LIBCPP_CONSTEXPR const bool is_signed = true;
308 static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;
309 static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;
Eric Fiseliere0ba2ba2016-12-08 07:30:01 +0000310 static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000311 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __FLT_MIN__;}
312 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __FLT_MAX__;}
313 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000314
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000315 static _LIBCPP_CONSTEXPR const bool is_integer = false;
316 static _LIBCPP_CONSTEXPR const bool is_exact = false;
317 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
318 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __FLT_EPSILON__;}
319 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5F;}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000320
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000321 static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;
322 static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;
323 static _LIBCPP_CONSTEXPR const int max_exponent = __FLT_MAX_EXP__;
324 static _LIBCPP_CONSTEXPR const int max_exponent10 = __FLT_MAX_10_EXP__;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000325
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000326 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
327 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
328 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
329 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
330 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
331 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_valf();}
332 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanf("");}
333 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansf("");}
334 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __FLT_DENORM_MIN__;}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000335
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000336 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
337 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
338 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000339
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000340 static _LIBCPP_CONSTEXPR const bool traps = false;
341 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
342 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000343};
344
345template <>
346class __libcpp_numeric_limits<double, true>
347{
348protected:
349 typedef double type;
350
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000351 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000352
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000353 static _LIBCPP_CONSTEXPR const bool is_signed = true;
354 static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;
355 static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;
Eric Fiseliere0ba2ba2016-12-08 07:30:01 +0000356 static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000357 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __DBL_MIN__;}
358 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __DBL_MAX__;}
359 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000360
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000361 static _LIBCPP_CONSTEXPR const bool is_integer = false;
362 static _LIBCPP_CONSTEXPR const bool is_exact = false;
363 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
364 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __DBL_EPSILON__;}
365 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5;}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000366
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000367 static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;
368 static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;
369 static _LIBCPP_CONSTEXPR const int max_exponent = __DBL_MAX_EXP__;
370 static _LIBCPP_CONSTEXPR const int max_exponent10 = __DBL_MAX_10_EXP__;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000371
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000372 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
373 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
374 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
375 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
376 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
377 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_val();}
378 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nan("");}
379 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nans("");}
380 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __DBL_DENORM_MIN__;}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000381
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000382 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
383 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
384 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000385
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000386 static _LIBCPP_CONSTEXPR const bool traps = false;
387 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
388 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000389};
390
391template <>
392class __libcpp_numeric_limits<long double, true>
393{
394protected:
395 typedef long double type;
396
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000397 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000398
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000399 static _LIBCPP_CONSTEXPR const bool is_signed = true;
400 static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;
401 static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;
Eric Fiseliere0ba2ba2016-12-08 07:30:01 +0000402 static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000403 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __LDBL_MIN__;}
404 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __LDBL_MAX__;}
405 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000406
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000407 static _LIBCPP_CONSTEXPR const bool is_integer = false;
408 static _LIBCPP_CONSTEXPR const bool is_exact = false;
409 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
410 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __LDBL_EPSILON__;}
411 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5;}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000412
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000413 static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;
414 static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;
415 static _LIBCPP_CONSTEXPR const int max_exponent = __LDBL_MAX_EXP__;
416 static _LIBCPP_CONSTEXPR const int max_exponent10 = __LDBL_MAX_10_EXP__;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000417
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000418 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
419 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
420 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
421 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
422 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
423 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_vall();}
424 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanl("");}
425 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
426 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000427
428#if (defined(__ppc__) || defined(__ppc64__))
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000429 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000430#else
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000431 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000432#endif
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000433 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
434 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000435
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000436 static _LIBCPP_CONSTEXPR const bool traps = false;
437 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
438 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000439};
440
441template <class _Tp>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000442class _LIBCPP_TEMPLATE_VIS numeric_limits
Howard Hinnantc51e1022010-05-11 19:42:16 +0000443 : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
444{
445 typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
446 typedef typename __base::type type;
447public:
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000448 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
449 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
450 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
451 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000452
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000453 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
454 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
455 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
456 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
457 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
458 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
459 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
460 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
461 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000462
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000463 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
464 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
465 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
466 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000467
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000468 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
469 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
470 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
471 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
472 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
473 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
474 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
475 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
476 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000477
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000478 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
479 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
480 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000481
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000482 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
483 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
484 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000485};
486
487template <class _Tp>
Howard Hinnant2c45cb42012-12-12 21:14:28 +0000488 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;
489template <class _Tp>
490 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;
491template <class _Tp>
492 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;
493template <class _Tp>
494 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;
495template <class _Tp>
496 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;
497template <class _Tp>
498 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;
499template <class _Tp>
500 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;
501template <class _Tp>
502 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;
503template <class _Tp>
504 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;
505template <class _Tp>
506 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;
507template <class _Tp>
508 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;
509template <class _Tp>
510 _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;
511template <class _Tp>
512 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;
513template <class _Tp>
514 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;
515template <class _Tp>
516 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;
517template <class _Tp>
518 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;
519template <class _Tp>
520 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;
521template <class _Tp>
522 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;
523template <class _Tp>
524 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;
525template <class _Tp>
526 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;
527template <class _Tp>
528 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;
529template <class _Tp>
530 _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;
531template <class _Tp>
532 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
533
534template <class _Tp>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000535class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000536 : private numeric_limits<_Tp>
537{
538 typedef numeric_limits<_Tp> __base;
539 typedef _Tp type;
540public:
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000541 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
542 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
543 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
544 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000545
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000546 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
547 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
548 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
549 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
550 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
551 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
552 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
553 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
554 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000555
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000556 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
557 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
558 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
559 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000560
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000561 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
562 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
563 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
564 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
565 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
566 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
567 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
568 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
569 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000570
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000571 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
572 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
573 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000574
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000575 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
576 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
577 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000578};
579
580template <class _Tp>
Howard Hinnant2c45cb42012-12-12 21:14:28 +0000581 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_specialized;
582template <class _Tp>
583 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits;
584template <class _Tp>
585 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits10;
586template <class _Tp>
587 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_digits10;
588template <class _Tp>
589 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_signed;
590template <class _Tp>
591 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_integer;
592template <class _Tp>
593 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_exact;
594template <class _Tp>
595 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::radix;
596template <class _Tp>
597 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent;
598template <class _Tp>
599 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent10;
600template <class _Tp>
601 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent;
602template <class _Tp>
603 _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent10;
604template <class _Tp>
605 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_infinity;
606template <class _Tp>
607 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_quiet_NaN;
608template <class _Tp>
609 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_signaling_NaN;
610template <class _Tp>
611 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const _Tp>::has_denorm;
612template <class _Tp>
613 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_denorm_loss;
614template <class _Tp>
615 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_iec559;
616template <class _Tp>
617 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_bounded;
618template <class _Tp>
619 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_modulo;
620template <class _Tp>
621 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::traps;
622template <class _Tp>
623 _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::tinyness_before;
624template <class _Tp>
625 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style;
626
627template <class _Tp>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000628class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000629 : private numeric_limits<_Tp>
630{
631 typedef numeric_limits<_Tp> __base;
632 typedef _Tp type;
633public:
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000634 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
635 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
636 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
637 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000638
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000639 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
640 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
641 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
642 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
643 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
644 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
645 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
646 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
647 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000648
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000649 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
650 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
651 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
652 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000653
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000654 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
655 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
656 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
657 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
658 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
659 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
660 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
661 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
662 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000663
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000664 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
665 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
666 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000667
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000668 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
669 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
670 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000671};
672
673template <class _Tp>
Howard Hinnant2c45cb42012-12-12 21:14:28 +0000674 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_specialized;
675template <class _Tp>
676 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits;
677template <class _Tp>
678 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits10;
679template <class _Tp>
680 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_digits10;
681template <class _Tp>
682 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_signed;
683template <class _Tp>
684 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_integer;
685template <class _Tp>
686 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_exact;
687template <class _Tp>
688 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::radix;
689template <class _Tp>
690 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent;
691template <class _Tp>
692 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent10;
693template <class _Tp>
694 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent;
695template <class _Tp>
696 _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent10;
697template <class _Tp>
698 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_infinity;
699template <class _Tp>
700 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_quiet_NaN;
701template <class _Tp>
702 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_signaling_NaN;
703template <class _Tp>
704 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<volatile _Tp>::has_denorm;
705template <class _Tp>
706 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_denorm_loss;
707template <class _Tp>
708 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_iec559;
709template <class _Tp>
710 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_bounded;
711template <class _Tp>
712 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_modulo;
713template <class _Tp>
714 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::traps;
715template <class _Tp>
716 _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::tinyness_before;
717template <class _Tp>
718 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style;
719
720template <class _Tp>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000721class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000722 : private numeric_limits<_Tp>
723{
724 typedef numeric_limits<_Tp> __base;
725 typedef _Tp type;
726public:
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000727 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
728 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
729 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
730 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000731
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000732 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
733 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
734 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
735 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
736 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
737 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
738 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
739 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
740 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000741
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000742 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
743 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
744 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
745 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000746
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000747 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
748 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
749 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
750 static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
751 static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
752 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
753 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
754 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
755 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000756
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000757 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
758 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
759 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000760
Howard Hinnant50ed0b22012-04-02 19:23:15 +0000761 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
762 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
763 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000764};
765
Howard Hinnant2c45cb42012-12-12 21:14:28 +0000766template <class _Tp>
767 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_specialized;
768template <class _Tp>
769 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits;
770template <class _Tp>
771 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits10;
772template <class _Tp>
Nico Weberf78c8f62014-05-30 12:09:47 +0000773 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_digits10;
Howard Hinnant2c45cb42012-12-12 21:14:28 +0000774template <class _Tp>
775 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_signed;
776template <class _Tp>
777 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_integer;
778template <class _Tp>
779 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_exact;
780template <class _Tp>
781 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::radix;
782template <class _Tp>
783 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent;
784template <class _Tp>
785 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent10;
786template <class _Tp>
787 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent;
788template <class _Tp>
789 _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent10;
790template <class _Tp>
791 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_infinity;
792template <class _Tp>
793 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_quiet_NaN;
794template <class _Tp>
795 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_signaling_NaN;
796template <class _Tp>
797 _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const volatile _Tp>::has_denorm;
798template <class _Tp>
799 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_denorm_loss;
800template <class _Tp>
801 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_iec559;
802template <class _Tp>
803 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_bounded;
804template <class _Tp>
805 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_modulo;
806template <class _Tp>
807 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::traps;
808template <class _Tp>
809 _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::tinyness_before;
810template <class _Tp>
811 _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const volatile _Tp>::round_style;
812
Howard Hinnantc51e1022010-05-11 19:42:16 +0000813_LIBCPP_END_NAMESPACE_STD
814
Eric Fiselierf4433a32017-05-31 22:07:49 +0000815_LIBCPP_POP_MACROS
816
Howard Hinnantc51e1022010-05-11 19:42:16 +0000817#endif // _LIBCPP_LIMITS