1 | /** @file
|
---|
2 | * IPRT / No-CRT - C++ limits header.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2022 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.alldomusa.eu.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_nocrt_limits
|
---|
27 | #define IPRT_INCLUDED_nocrt_limits
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <iprt/nocrt/limits.h>
|
---|
33 |
|
---|
34 | namespace std
|
---|
35 | {
|
---|
36 | enum float_denorm_style
|
---|
37 | {
|
---|
38 | denorm_indeterminate = -1,
|
---|
39 | denorm_absent,
|
---|
40 | denorm_present,
|
---|
41 | };
|
---|
42 |
|
---|
43 | enum float_round_style
|
---|
44 | {
|
---|
45 | round_indeterminate = -1,
|
---|
46 | round_toward_zero,
|
---|
47 | round_to_nearest,
|
---|
48 | round_toward_infinity,
|
---|
49 | round_toward_neg_infinity,
|
---|
50 | };
|
---|
51 |
|
---|
52 | struct rtNoCrtLimitNumericBase
|
---|
53 | {
|
---|
54 | static const bool is_specialized = false;
|
---|
55 | static const bool is_integer = false;
|
---|
56 | static const bool is_signed = false;
|
---|
57 | static const bool is_exact = false;
|
---|
58 | static const bool is_bounded = false;
|
---|
59 |
|
---|
60 | static const bool has_infinity = false;
|
---|
61 | static const bool has_quiet_NaN = false;
|
---|
62 | static const bool has_signaling_NaN = false;
|
---|
63 | static const bool has_denorm_loss = false;
|
---|
64 | static const bool is_iec559 = false;
|
---|
65 | static const bool is_modulo = false;
|
---|
66 | static const bool traps = false;
|
---|
67 | static const bool tinyness_before = false;
|
---|
68 |
|
---|
69 | static const int digits = 0;
|
---|
70 | static const int digits10 = 0;
|
---|
71 | static const int max_digits10 = 0;
|
---|
72 | static const int radix = 0;
|
---|
73 | static const int min_exponent = 0;
|
---|
74 | static const int min_exponent10 = 0;
|
---|
75 | static const int max_exponent = 0;
|
---|
76 | static const int max_exponent10 = 0;
|
---|
77 |
|
---|
78 | static const float_denorm_style has_denorm = denorm_absent;
|
---|
79 | static const float_round_style round_style = round_toward_zero;
|
---|
80 | };
|
---|
81 |
|
---|
82 | struct rtNoCrtLimitNumericIntBase : public rtNoCrtLimitNumericBase
|
---|
83 | {
|
---|
84 | static const bool is_specialized = true;
|
---|
85 | static const bool is_integer = true;
|
---|
86 | static const bool is_exact = true;
|
---|
87 | static const bool is_bounded = true;
|
---|
88 | static const int radix = 2;
|
---|
89 | };
|
---|
90 |
|
---|
91 | struct rtNoCrtLimitNumericFloatBase : public rtNoCrtLimitNumericBase
|
---|
92 | {
|
---|
93 | static const bool is_specialized = true;
|
---|
94 | static const bool is_signed = true;
|
---|
95 | static const bool is_bounded = true;
|
---|
96 | static const bool has_infinity = false;
|
---|
97 | static const bool has_quiet_NaN = false;
|
---|
98 | static const bool has_signaling_NaN = false;
|
---|
99 | static const bool is_iec559 = false;
|
---|
100 | static const int radix = FLT_RADIX;
|
---|
101 | static const float_denorm_style has_denorm = denorm_present;
|
---|
102 | static const float_round_style round_style = round_to_nearest;
|
---|
103 | };
|
---|
104 |
|
---|
105 | /*
|
---|
106 | * Generic template.
|
---|
107 | */
|
---|
108 | template<typename a_Type>
|
---|
109 | struct numeric_limits : public rtNoCrtLimitNumericBase
|
---|
110 | {
|
---|
111 | /** @todo need a RT_CONSTEXPR_FN etc */
|
---|
112 | static constexpr a_Type(min)() RT_NOEXCEPT { return a_Type(); }
|
---|
113 | static constexpr a_Type(max)() RT_NOEXCEPT { return a_Type(); }
|
---|
114 | static constexpr a_Type lowest() RT_NOEXCEPT { return a_Type(); }
|
---|
115 | static constexpr a_Type epsilon() RT_NOEXCEPT { return a_Type(); }
|
---|
116 | static constexpr a_Type round_error() RT_NOEXCEPT { return a_Type(); }
|
---|
117 | static constexpr a_Type infinity() RT_NOEXCEPT { return a_Type(); }
|
---|
118 | static constexpr a_Type quiet_NaN() RT_NOEXCEPT { return a_Type(); }
|
---|
119 | static constexpr a_Type signaling_NaN() RT_NOEXCEPT { return a_Type(); }
|
---|
120 | static constexpr a_Type denorm_min() RT_NOEXCEPT { return a_Type(); }
|
---|
121 | };
|
---|
122 |
|
---|
123 | /* const and volatile trickery: */
|
---|
124 | template<typename a_Type> struct numeric_limits<const a_Type> : public numeric_limits<a_Type> {};
|
---|
125 | template<typename a_Type> struct numeric_limits<volatile a_Type> : public numeric_limits<a_Type> {};
|
---|
126 | template<typename a_Type> struct numeric_limits<const volatile a_Type> : public numeric_limits<a_Type> {};
|
---|
127 |
|
---|
128 | /*
|
---|
129 | * Integer specializations.
|
---|
130 | */
|
---|
131 | template<>
|
---|
132 | struct numeric_limits<bool> : public rtNoCrtLimitNumericIntBase
|
---|
133 | {
|
---|
134 | static constexpr bool(min)() RT_NOEXCEPT { return false; }
|
---|
135 | static constexpr bool(max)() RT_NOEXCEPT { return true; }
|
---|
136 | static constexpr bool lowest() RT_NOEXCEPT { return false; }
|
---|
137 | static constexpr bool epsilon() RT_NOEXCEPT { return false; }
|
---|
138 | static constexpr bool round_error() RT_NOEXCEPT { return false; }
|
---|
139 | static constexpr bool infinity() RT_NOEXCEPT { return false; }
|
---|
140 | static constexpr bool quiet_NaN() RT_NOEXCEPT { return false; }
|
---|
141 | static constexpr bool signaling_NaN() RT_NOEXCEPT { return false; }
|
---|
142 | static constexpr bool denorm_min() RT_NOEXCEPT { return false; }
|
---|
143 | static const int digits = 1;
|
---|
144 | };
|
---|
145 |
|
---|
146 | template<>
|
---|
147 | struct numeric_limits<char> : public rtNoCrtLimitNumericIntBase
|
---|
148 | {
|
---|
149 | static constexpr char(min)() RT_NOEXCEPT { return CHAR_MIN; }
|
---|
150 | static constexpr char(max)() RT_NOEXCEPT { return CHAR_MAX; }
|
---|
151 | static constexpr char lowest() RT_NOEXCEPT { return CHAR_MIN; }
|
---|
152 | static constexpr char epsilon() RT_NOEXCEPT { return 0; }
|
---|
153 | static constexpr char round_error() RT_NOEXCEPT { return 0; }
|
---|
154 | static constexpr char infinity() RT_NOEXCEPT { return 0; }
|
---|
155 | static constexpr char quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
156 | static constexpr char signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
157 | static constexpr char denorm_min() RT_NOEXCEPT { return 0; }
|
---|
158 |
|
---|
159 | static const bool is_signed = (char)(-1) < 0;
|
---|
160 | static const bool is_modulo = (char)(-1) > 0;
|
---|
161 | static const int digits = (char)(-1) < 0 ? CHAR_BIT - 1 : CHAR_BIT;
|
---|
162 | static const int digits10 = 2;
|
---|
163 | };
|
---|
164 |
|
---|
165 | template<>
|
---|
166 | struct numeric_limits<signed char> : public rtNoCrtLimitNumericIntBase
|
---|
167 | {
|
---|
168 | static constexpr signed char(min)() RT_NOEXCEPT { return SCHAR_MIN; }
|
---|
169 | static constexpr signed char(max)() RT_NOEXCEPT { return SCHAR_MAX; }
|
---|
170 | static constexpr signed char lowest() RT_NOEXCEPT { return SCHAR_MIN; }
|
---|
171 | static constexpr signed char epsilon() RT_NOEXCEPT { return 0; }
|
---|
172 | static constexpr signed char round_error() RT_NOEXCEPT { return 0; }
|
---|
173 | static constexpr signed char infinity() RT_NOEXCEPT { return 0; }
|
---|
174 | static constexpr signed char quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
175 | static constexpr signed char signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
176 | static constexpr signed char denorm_min() RT_NOEXCEPT { return 0; }
|
---|
177 |
|
---|
178 | static const bool is_signed = true;
|
---|
179 | static const int digits = CHAR_BIT - 1;
|
---|
180 | static const int digits10 = 2;
|
---|
181 | };
|
---|
182 |
|
---|
183 | template<>
|
---|
184 | struct numeric_limits<unsigned char> : public rtNoCrtLimitNumericIntBase
|
---|
185 | {
|
---|
186 | static constexpr unsigned char(min)() RT_NOEXCEPT { return 0; }
|
---|
187 | static constexpr unsigned char(max)() RT_NOEXCEPT { return UCHAR_MAX; }
|
---|
188 | static constexpr unsigned char lowest() RT_NOEXCEPT { return 0; }
|
---|
189 | static constexpr unsigned char epsilon() RT_NOEXCEPT { return 0; }
|
---|
190 | static constexpr unsigned char round_error() RT_NOEXCEPT { return 0; }
|
---|
191 | static constexpr unsigned char infinity() RT_NOEXCEPT { return 0; }
|
---|
192 | static constexpr unsigned char quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
193 | static constexpr unsigned char signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
194 | static constexpr unsigned char denorm_min() RT_NOEXCEPT { return 0; }
|
---|
195 |
|
---|
196 | static const bool is_modulo = true;
|
---|
197 | static const int digits = CHAR_BIT;
|
---|
198 | static const int digits10 = 2;
|
---|
199 | };
|
---|
200 |
|
---|
201 | /** @todo wchar_t, char8_t, char16_t, char32_t */
|
---|
202 |
|
---|
203 | template<>
|
---|
204 | struct numeric_limits<short> : public rtNoCrtLimitNumericIntBase
|
---|
205 | {
|
---|
206 | static constexpr short(min)() RT_NOEXCEPT { return SHRT_MIN; }
|
---|
207 | static constexpr short(max)() RT_NOEXCEPT { return SHRT_MAX; }
|
---|
208 | static constexpr short lowest() RT_NOEXCEPT { return SHRT_MIN; }
|
---|
209 | static constexpr short epsilon() RT_NOEXCEPT { return 0; }
|
---|
210 | static constexpr short round_error() RT_NOEXCEPT { return 0; }
|
---|
211 | static constexpr short infinity() RT_NOEXCEPT { return 0; }
|
---|
212 | static constexpr short quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
213 | static constexpr short signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
214 | static constexpr short denorm_min() RT_NOEXCEPT { return 0; }
|
---|
215 |
|
---|
216 | static const bool is_signed = true;
|
---|
217 | static const int digits = CHAR_BIT * sizeof(short) - 1;
|
---|
218 | static const int digits10 = 4;
|
---|
219 | };
|
---|
220 |
|
---|
221 | template<>
|
---|
222 | struct numeric_limits<unsigned short> : public rtNoCrtLimitNumericIntBase
|
---|
223 | {
|
---|
224 | static constexpr unsigned short(min)() RT_NOEXCEPT { return 0; }
|
---|
225 | static constexpr unsigned short(max)() RT_NOEXCEPT { return USHRT_MAX; }
|
---|
226 | static constexpr unsigned short lowest() RT_NOEXCEPT { return 0; }
|
---|
227 | static constexpr unsigned short epsilon() RT_NOEXCEPT { return 0; }
|
---|
228 | static constexpr unsigned short round_error() RT_NOEXCEPT { return 0; }
|
---|
229 | static constexpr unsigned short infinity() RT_NOEXCEPT { return 0; }
|
---|
230 | static constexpr unsigned short quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
231 | static constexpr unsigned short signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
232 | static constexpr unsigned short denorm_min() RT_NOEXCEPT { return 0; }
|
---|
233 |
|
---|
234 | static const bool is_modulo = true;
|
---|
235 | static const int digits = CHAR_BIT * sizeof(unsigned short);
|
---|
236 | static const int digits10 = 4;
|
---|
237 | };
|
---|
238 |
|
---|
239 | # if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
|
---|
240 | template<>
|
---|
241 | struct numeric_limits<wchar_t> : public rtNoCrtLimitNumericIntBase
|
---|
242 | {
|
---|
243 | static constexpr wchar_t(min)() RT_NOEXCEPT { return WCHAR_MIN; }
|
---|
244 | static constexpr wchar_t(max)() RT_NOEXCEPT { return WCHAR_MAX; }
|
---|
245 | static constexpr wchar_t lowest() RT_NOEXCEPT { return WCHAR_MIN; }
|
---|
246 | static constexpr wchar_t epsilon() RT_NOEXCEPT { return 0; }
|
---|
247 | static constexpr wchar_t round_error() RT_NOEXCEPT { return 0; }
|
---|
248 | static constexpr wchar_t infinity() RT_NOEXCEPT { return 0; }
|
---|
249 | static constexpr wchar_t quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
250 | static constexpr wchar_t signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
251 | static constexpr wchar_t denorm_min() RT_NOEXCEPT { return 0; }
|
---|
252 |
|
---|
253 | static const bool is_modulo = true;
|
---|
254 | static const int digits = CHAR_BIT * sizeof(wchar_t);
|
---|
255 | static const int digits10 = sizeof(wchar_t) == 2 ? 4 : 9; /** @todo ASSUMES wchar_t is either 16 or 32 bits */
|
---|
256 | };
|
---|
257 | # endif
|
---|
258 |
|
---|
259 | template<>
|
---|
260 | struct numeric_limits<char16_t> : public rtNoCrtLimitNumericIntBase
|
---|
261 | {
|
---|
262 | static constexpr char16_t(min)() RT_NOEXCEPT { return 0; }
|
---|
263 | static constexpr char16_t(max)() RT_NOEXCEPT { return USHRT_MAX; }
|
---|
264 | static constexpr char16_t lowest() RT_NOEXCEPT { return 0; }
|
---|
265 | static constexpr char16_t epsilon() RT_NOEXCEPT { return 0; }
|
---|
266 | static constexpr char16_t round_error() RT_NOEXCEPT { return 0; }
|
---|
267 | static constexpr char16_t infinity() RT_NOEXCEPT { return 0; }
|
---|
268 | static constexpr char16_t quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
269 | static constexpr char16_t signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
270 | static constexpr char16_t denorm_min() RT_NOEXCEPT { return 0; }
|
---|
271 |
|
---|
272 | static const bool is_modulo = true;
|
---|
273 | static const int digits = CHAR_BIT * sizeof(char16_t);
|
---|
274 | static const int digits10 = 4;
|
---|
275 | };
|
---|
276 |
|
---|
277 | template<>
|
---|
278 | struct numeric_limits<int> : public rtNoCrtLimitNumericIntBase
|
---|
279 | {
|
---|
280 | static constexpr int(min)() RT_NOEXCEPT { return INT_MIN; }
|
---|
281 | static constexpr int(max)() RT_NOEXCEPT { return INT_MAX; }
|
---|
282 | static constexpr int lowest() RT_NOEXCEPT { return INT_MIN; }
|
---|
283 | static constexpr int epsilon() RT_NOEXCEPT { return 0; }
|
---|
284 | static constexpr int round_error() RT_NOEXCEPT { return 0; }
|
---|
285 | static constexpr int infinity() RT_NOEXCEPT { return 0; }
|
---|
286 | static constexpr int quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
287 | static constexpr int signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
288 | static constexpr int denorm_min() RT_NOEXCEPT { return 0; }
|
---|
289 |
|
---|
290 | static const bool is_signed = true;
|
---|
291 | static const int digits = CHAR_BIT * sizeof(int) - 1;
|
---|
292 | static const int digits10 = 9;
|
---|
293 | };
|
---|
294 |
|
---|
295 | template<>
|
---|
296 | struct numeric_limits<unsigned int> : public rtNoCrtLimitNumericIntBase
|
---|
297 | {
|
---|
298 | static constexpr unsigned int(min)() RT_NOEXCEPT { return 0; }
|
---|
299 | static constexpr unsigned int(max)() RT_NOEXCEPT { return UINT_MAX; }
|
---|
300 | static constexpr unsigned int lowest() RT_NOEXCEPT { return 0; }
|
---|
301 | static constexpr unsigned int epsilon() RT_NOEXCEPT { return 0; }
|
---|
302 | static constexpr unsigned int round_error() RT_NOEXCEPT { return 0; }
|
---|
303 | static constexpr unsigned int infinity() RT_NOEXCEPT { return 0; }
|
---|
304 | static constexpr unsigned int quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
305 | static constexpr unsigned int signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
306 | static constexpr unsigned int denorm_min() RT_NOEXCEPT { return 0; }
|
---|
307 |
|
---|
308 | static const bool is_modulo = true;
|
---|
309 | static const int digits = CHAR_BIT * sizeof(unsigned int);
|
---|
310 | static const int digits10 = 9;
|
---|
311 | };
|
---|
312 |
|
---|
313 | template<>
|
---|
314 | struct numeric_limits<char32_t> : public rtNoCrtLimitNumericIntBase
|
---|
315 | {
|
---|
316 | static constexpr char32_t(min)() RT_NOEXCEPT { return 0; }
|
---|
317 | static constexpr char32_t(max)() RT_NOEXCEPT { return UINT_MAX; }
|
---|
318 | static constexpr char32_t lowest() RT_NOEXCEPT { return 0; }
|
---|
319 | static constexpr char32_t epsilon() RT_NOEXCEPT { return 0; }
|
---|
320 | static constexpr char32_t round_error() RT_NOEXCEPT { return 0; }
|
---|
321 | static constexpr char32_t infinity() RT_NOEXCEPT { return 0; }
|
---|
322 | static constexpr char32_t quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
323 | static constexpr char32_t signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
324 | static constexpr char32_t denorm_min() RT_NOEXCEPT { return 0; }
|
---|
325 |
|
---|
326 | static const bool is_modulo = true;
|
---|
327 | static const int digits = CHAR_BIT * sizeof(char32_t);
|
---|
328 | static const int digits10 = 9;
|
---|
329 | };
|
---|
330 |
|
---|
331 | template<>
|
---|
332 | struct numeric_limits<long> : public rtNoCrtLimitNumericIntBase
|
---|
333 | {
|
---|
334 | static constexpr long(min)() RT_NOEXCEPT { return LONG_MIN; }
|
---|
335 | static constexpr long(max)() RT_NOEXCEPT { return LONG_MAX; }
|
---|
336 | static constexpr long lowest() RT_NOEXCEPT { return LONG_MIN; }
|
---|
337 | static constexpr long epsilon() RT_NOEXCEPT { return 0; }
|
---|
338 | static constexpr long round_error() RT_NOEXCEPT { return 0; }
|
---|
339 | static constexpr long infinity() RT_NOEXCEPT { return 0; }
|
---|
340 | static constexpr long quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
341 | static constexpr long signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
342 | static constexpr long denorm_min() RT_NOEXCEPT { return 0; }
|
---|
343 |
|
---|
344 | static const bool is_signed = true;
|
---|
345 | static const int digits = CHAR_BIT * sizeof(long) - 1;
|
---|
346 | static const int digits10 = sizeof(long) == sizeof(int) ? 9 : 18;
|
---|
347 | };
|
---|
348 |
|
---|
349 | template<>
|
---|
350 | struct numeric_limits<unsigned long> : public rtNoCrtLimitNumericIntBase
|
---|
351 | {
|
---|
352 | static constexpr unsigned long(min)() RT_NOEXCEPT { return 0; }
|
---|
353 | static constexpr unsigned long(max)() RT_NOEXCEPT { return ULONG_MAX; }
|
---|
354 | static constexpr unsigned long lowest() RT_NOEXCEPT { return 0; }
|
---|
355 | static constexpr unsigned long epsilon() RT_NOEXCEPT { return 0; }
|
---|
356 | static constexpr unsigned long round_error() RT_NOEXCEPT { return 0; }
|
---|
357 | static constexpr unsigned long infinity() RT_NOEXCEPT { return 0; }
|
---|
358 | static constexpr unsigned long quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
359 | static constexpr unsigned long signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
360 | static constexpr unsigned long denorm_min() RT_NOEXCEPT { return 0; }
|
---|
361 |
|
---|
362 | static const bool is_modulo = true;
|
---|
363 | static const int digits = CHAR_BIT * sizeof(unsigned long);
|
---|
364 | static const int digits10 = sizeof(unsigned long) == sizeof(unsigned int) ? 9 : 19;
|
---|
365 | };
|
---|
366 |
|
---|
367 | template<>
|
---|
368 | struct numeric_limits<long long> : public rtNoCrtLimitNumericIntBase
|
---|
369 | {
|
---|
370 | static constexpr long long(min)() RT_NOEXCEPT { return LLONG_MIN; }
|
---|
371 | static constexpr long long(max)() RT_NOEXCEPT { return LLONG_MAX; }
|
---|
372 | static constexpr long long lowest() RT_NOEXCEPT { return LLONG_MIN; }
|
---|
373 | static constexpr long long epsilon() RT_NOEXCEPT { return 0; }
|
---|
374 | static constexpr long long round_error() RT_NOEXCEPT { return 0; }
|
---|
375 | static constexpr long long infinity() RT_NOEXCEPT { return 0; }
|
---|
376 | static constexpr long long quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
377 | static constexpr long long signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
378 | static constexpr long long denorm_min() RT_NOEXCEPT { return 0; }
|
---|
379 |
|
---|
380 | static const bool is_signed = true;
|
---|
381 | static const int digits = CHAR_BIT * sizeof(long long) - 1;
|
---|
382 | static const int digits10 = 18;
|
---|
383 | };
|
---|
384 |
|
---|
385 | template<>
|
---|
386 | struct numeric_limits<unsigned long long> : public rtNoCrtLimitNumericIntBase
|
---|
387 | {
|
---|
388 | static constexpr unsigned long long(min)() RT_NOEXCEPT { return 0; }
|
---|
389 | static constexpr unsigned long long(max)() RT_NOEXCEPT { return ULLONG_MAX; }
|
---|
390 | static constexpr unsigned long long lowest() RT_NOEXCEPT { return 0; }
|
---|
391 | static constexpr unsigned long long epsilon() RT_NOEXCEPT { return 0; }
|
---|
392 | static constexpr unsigned long long round_error() RT_NOEXCEPT { return 0; }
|
---|
393 | static constexpr unsigned long long infinity() RT_NOEXCEPT { return 0; }
|
---|
394 | static constexpr unsigned long long quiet_NaN() RT_NOEXCEPT { return 0; }
|
---|
395 | static constexpr unsigned long long signaling_NaN() RT_NOEXCEPT { return 0; }
|
---|
396 | static constexpr unsigned long long denorm_min() RT_NOEXCEPT { return 0; }
|
---|
397 |
|
---|
398 | static const bool is_modulo = true;
|
---|
399 | static const int digits = CHAR_BIT * sizeof(unsigned long long);
|
---|
400 | static const int digits10 = 19;
|
---|
401 | };
|
---|
402 |
|
---|
403 |
|
---|
404 | /*
|
---|
405 | * Floating point.
|
---|
406 | */
|
---|
407 | template<>
|
---|
408 | struct numeric_limits<float> : public rtNoCrtLimitNumericFloatBase
|
---|
409 | {
|
---|
410 | static constexpr float(min)() RT_NOEXCEPT { return FLT_MIN; }
|
---|
411 | static constexpr float(max)() RT_NOEXCEPT { return FLT_MAX; }
|
---|
412 | static constexpr float lowest() RT_NOEXCEPT { return -(FLT_MAX); }
|
---|
413 | static constexpr float epsilon() RT_NOEXCEPT { return FLT_EPSILON; }
|
---|
414 | static constexpr float round_error() RT_NOEXCEPT { return 0.5F; }
|
---|
415 | static constexpr float infinity() RT_NOEXCEPT { return __builtin_huge_valf(); }
|
---|
416 | static constexpr float quiet_NaN() RT_NOEXCEPT { return __builtin_nanf("0"); }
|
---|
417 | static constexpr float signaling_NaN() RT_NOEXCEPT { return __builtin_nansf("1"); }
|
---|
418 | static constexpr float denorm_min() RT_NOEXCEPT { return FLT_TRUE_MIN; }
|
---|
419 |
|
---|
420 | static const int digits = FLT_MANT_DIG;
|
---|
421 | static const int digits10 = FLT_DIG;
|
---|
422 | static const int max_digits10 = FLT_DECIMAL_DIG;
|
---|
423 | static const int max_exponent = FLT_MAX_EXP;
|
---|
424 | static const int max_exponent10 = FLT_MAX_10_EXP;
|
---|
425 | static const int min_exponent = FLT_MIN_EXP;
|
---|
426 | static const int min_exponent10 = FLT_MIN_10_EXP;
|
---|
427 | };
|
---|
428 |
|
---|
429 | template<>
|
---|
430 | struct numeric_limits<double> : public rtNoCrtLimitNumericFloatBase
|
---|
431 | {
|
---|
432 | static constexpr double(min)() RT_NOEXCEPT { return DBL_MIN; }
|
---|
433 | static constexpr double(max)() RT_NOEXCEPT { return DBL_MAX; }
|
---|
434 | static constexpr double lowest() RT_NOEXCEPT { return -(DBL_MAX); }
|
---|
435 | static constexpr double epsilon() RT_NOEXCEPT { return DBL_EPSILON; }
|
---|
436 | static constexpr double round_error() RT_NOEXCEPT { return 0.5; }
|
---|
437 | static constexpr double infinity() RT_NOEXCEPT { return __builtin_huge_val(); }
|
---|
438 | static constexpr double quiet_NaN() RT_NOEXCEPT { return __builtin_nan("0"); }
|
---|
439 | static constexpr double signaling_NaN() RT_NOEXCEPT { return __builtin_nans("1"); }
|
---|
440 | static constexpr double denorm_min() RT_NOEXCEPT { return DBL_TRUE_MIN; }
|
---|
441 |
|
---|
442 | static const int digits = DBL_MANT_DIG;
|
---|
443 | static const int digits10 = DBL_DIG;
|
---|
444 | static const int max_digits10 = DBL_DECIMAL_DIG;
|
---|
445 | static const int max_exponent = DBL_MAX_EXP;
|
---|
446 | static const int max_exponent10 = DBL_MAX_10_EXP;
|
---|
447 | static const int min_exponent = DBL_MIN_EXP;
|
---|
448 | static const int min_exponent10 = DBL_MIN_10_EXP;
|
---|
449 | };
|
---|
450 |
|
---|
451 | template<>
|
---|
452 | struct numeric_limits<long double> : public rtNoCrtLimitNumericFloatBase
|
---|
453 | {
|
---|
454 | static constexpr long double(min)() RT_NOEXCEPT { return LDBL_MIN; }
|
---|
455 | static constexpr long double(max)() RT_NOEXCEPT { return LDBL_MAX; }
|
---|
456 | static constexpr long double lowest() RT_NOEXCEPT { return -(LDBL_MAX); }
|
---|
457 | static constexpr long double epsilon() RT_NOEXCEPT { return LDBL_EPSILON; }
|
---|
458 | static constexpr long double round_error() RT_NOEXCEPT { return 0.5L; }
|
---|
459 | #if LDBL_DIG == DBL_DIG
|
---|
460 | static constexpr long double infinity() RT_NOEXCEPT { return __builtin_huge_val(); }
|
---|
461 | static constexpr long double quiet_NaN() RT_NOEXCEPT { return __builtin_nan("0"); }
|
---|
462 | static constexpr long double signaling_NaN() RT_NOEXCEPT { return __builtin_nans("1"); }
|
---|
463 | #else
|
---|
464 | static constexpr long double infinity() RT_NOEXCEPT { return __builtin_huge_vall(); }
|
---|
465 | static constexpr long double quiet_NaN() RT_NOEXCEPT { return __builtin_nanl("0"); }
|
---|
466 | static constexpr long double signaling_NaN() RT_NOEXCEPT { return __builtin_nansl("1"); }
|
---|
467 | #endif
|
---|
468 | static constexpr long double denorm_min() RT_NOEXCEPT { return LDBL_TRUE_MIN; }
|
---|
469 |
|
---|
470 | static const int digits = LDBL_MANT_DIG;
|
---|
471 | static const int digits10 = LDBL_DIG;
|
---|
472 | static const int max_digits10 = LDBL_DECIMAL_DIG;
|
---|
473 | static const int max_exponent = LDBL_MAX_EXP;
|
---|
474 | static const int max_exponent10 = LDBL_MAX_10_EXP;
|
---|
475 | static const int min_exponent = LDBL_MIN_EXP;
|
---|
476 | static const int min_exponent10 = LDBL_MIN_10_EXP;
|
---|
477 | };
|
---|
478 |
|
---|
479 | /** @todo more types */
|
---|
480 | }
|
---|
481 |
|
---|
482 | #endif /* !IPRT_INCLUDED_nocrt_limits */
|
---|
483 |
|
---|