[a3067af] | 1 | /*
|
---|
[b57a3ee] | 2 | * Copyright (c) 2018 Jaroslav Jindrak
|
---|
[a3067af] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[b57a3ee] | 29 | #ifndef LIBCPP_BITS_LIMITS
|
---|
| 30 | #define LIBCPP_BITS_LIMITS
|
---|
[a3067af] | 31 |
|
---|
| 32 | #include <cstdint>
|
---|
[092a436] | 33 | #include <climits>
|
---|
[a3067af] | 34 |
|
---|
| 35 | namespace std
|
---|
| 36 | {
|
---|
| 37 |
|
---|
| 38 | /**
|
---|
| 39 | * 18.3.2.5, type float_round_style:
|
---|
| 40 | */
|
---|
| 41 |
|
---|
| 42 | enum float_round_style
|
---|
| 43 | {
|
---|
| 44 | round_indeterminate = -1,
|
---|
| 45 | round_toward_zero = 0,
|
---|
| 46 | round_to_nearest = 1,
|
---|
| 47 | round_toward_infinity = 2,
|
---|
| 48 | round_toward_neg_infinity = 3
|
---|
| 49 | };
|
---|
| 50 |
|
---|
| 51 | /**
|
---|
| 52 | * 18.3.2.6, type float_denorm_style:
|
---|
| 53 | */
|
---|
| 54 |
|
---|
| 55 | enum float_denorm_style
|
---|
| 56 | {
|
---|
| 57 | denorm_indeterminate = -1,
|
---|
| 58 | denorm_absent = 0,
|
---|
| 59 | denorm_present = 1
|
---|
| 60 | };
|
---|
| 61 |
|
---|
| 62 | /**
|
---|
| 63 | * 18.3.2.3, class template numeric_limits:
|
---|
| 64 | */
|
---|
| 65 |
|
---|
| 66 | namespace aux
|
---|
| 67 | {
|
---|
| 68 | template<class T>
|
---|
| 69 | class numeric_limits
|
---|
| 70 | {
|
---|
| 71 | public:
|
---|
| 72 | static constexpr bool is_specialized = false;
|
---|
| 73 |
|
---|
| 74 | static constexpr T min() noexcept
|
---|
| 75 | {
|
---|
| 76 | return T{};
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | static constexpr T max() noexcept
|
---|
| 80 | {
|
---|
| 81 | return T{};
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | static constexpr T lowest() noexcept
|
---|
| 85 | {
|
---|
| 86 | return T{};
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | static constexpr int digits = 0;
|
---|
| 90 | static constexpr int digits10 = 0;
|
---|
| 91 | static constexpr int max_digits10 = 0;
|
---|
| 92 |
|
---|
| 93 | static constexpr bool is_signed = false;
|
---|
| 94 | static constexpr bool is_integer = false;
|
---|
| 95 | static constexpr bool is_exact = false;
|
---|
| 96 |
|
---|
| 97 | static constexpr int radix = 0;
|
---|
| 98 |
|
---|
| 99 | static constexpr T epsilon() noexcept
|
---|
| 100 | {
|
---|
| 101 | return T{};
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | static constexpr T round_error() noexcept
|
---|
| 105 | {
|
---|
| 106 | return T{};
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | static constexpr int min_exponent = 0;
|
---|
| 110 | static constexpr int min_exponent10 = 0;
|
---|
| 111 | static constexpr int max_exponent = 0;
|
---|
| 112 | static constexpr int max_exponent10 = 0;
|
---|
| 113 |
|
---|
| 114 | static constexpr bool has_infinity = false;
|
---|
| 115 | static constexpr bool has_quiet_NaN = false;
|
---|
| 116 | static constexpr bool has_signaling_NaN = false;
|
---|
| 117 |
|
---|
| 118 | static constexpr float_denorm_style has_denorm = denorm_absent;
|
---|
| 119 | static constexpr bool has_denorm_loss = false;
|
---|
| 120 |
|
---|
| 121 | static constexpr T infinity() noexcept
|
---|
| 122 | {
|
---|
| 123 | return T{};
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | static constexpr T quiet_NaN() noexcept
|
---|
| 127 | {
|
---|
| 128 | return T{};
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | static constexpr T signaling_NaN() noexcept
|
---|
| 132 | {
|
---|
| 133 | return T{};
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | static constexpr T denorm_min() noexcept
|
---|
| 137 | {
|
---|
| 138 | return T{};
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | static constexpr bool is_iec559 = false;
|
---|
| 142 | static constexpr bool is_bounded = false;
|
---|
| 143 | static constexpr bool is_modulo = false;
|
---|
| 144 |
|
---|
| 145 | static constexpr bool traps = false;
|
---|
| 146 | static constexpr bool tinyness_before = false;
|
---|
| 147 |
|
---|
| 148 | static constexpr float_round_style round_style = round_toward_zero;
|
---|
| 149 | };
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | template<class T>
|
---|
| 153 | class numeric_limits: public aux::numeric_limits<T>
|
---|
| 154 | { /* DUMMY BODY */ };
|
---|
| 155 |
|
---|
| 156 | template<class T>
|
---|
| 157 | class numeric_limits<const T>: public numeric_limits<T>
|
---|
| 158 | { /* DUMMY BODY */ };
|
---|
| 159 |
|
---|
| 160 | template<class T>
|
---|
| 161 | class numeric_limits<volatile T>: public numeric_limits<T>
|
---|
| 162 | { /* DUMMY BODY */ };
|
---|
| 163 |
|
---|
| 164 | template<class T>
|
---|
| 165 | class numeric_limits<const volatile T>: public numeric_limits<T>
|
---|
| 166 | { /* DUMMY BODY */ };
|
---|
| 167 |
|
---|
| 168 | /**
|
---|
| 169 | * 18.3.2.3, class template numeric_limits:
|
---|
| 170 | */
|
---|
| 171 |
|
---|
| 172 | template<>
|
---|
| 173 | class numeric_limits<float>
|
---|
| 174 | {
|
---|
| 175 | public:
|
---|
| 176 | static constexpr bool is_specialized = true;
|
---|
| 177 |
|
---|
| 178 | static constexpr float min() noexcept
|
---|
| 179 | {
|
---|
| 180 | return 1.17549435e-38f;
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | static constexpr float max() noexcept
|
---|
| 184 | {
|
---|
| 185 | return 3.40282347e+38f;
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | static constexpr float lowest() noexcept
|
---|
| 189 | {
|
---|
| 190 | return -3.40282347e+38f;
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | static constexpr int digits = 24;
|
---|
| 194 | static constexpr int digits10 = 6;
|
---|
| 195 | static constexpr int max_digits10 = 9;
|
---|
| 196 |
|
---|
| 197 | static constexpr bool is_signed = true;
|
---|
| 198 | static constexpr bool is_integer = false;
|
---|
| 199 | static constexpr bool is_exact = false;
|
---|
| 200 |
|
---|
| 201 | static constexpr int radix = 2;
|
---|
| 202 |
|
---|
| 203 | static constexpr float epsilon() noexcept
|
---|
| 204 | {
|
---|
| 205 | return 1.19209290e-07f;
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | static constexpr float round_error() noexcept
|
---|
| 209 | {
|
---|
| 210 | return 0.5f;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | static constexpr int min_exponent = -127;
|
---|
| 214 | static constexpr int min_exponent10 = -37;
|
---|
| 215 | static constexpr int max_exponent = 128;
|
---|
| 216 | static constexpr int max_exponent10 = 38;
|
---|
| 217 |
|
---|
| 218 | static constexpr bool has_infinity = true;
|
---|
| 219 | static constexpr bool has_quiet_NaN = true;
|
---|
| 220 | static constexpr bool has_signaling_NaN = true;
|
---|
| 221 |
|
---|
| 222 | static constexpr float_denorm_style has_denorm = denorm_absent;
|
---|
| 223 | static constexpr bool has_denorm_loss = false;
|
---|
| 224 |
|
---|
| 225 | static constexpr float infinity() noexcept
|
---|
| 226 | {
|
---|
| 227 | // TODO: implement
|
---|
| 228 | return 0.f;
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | static constexpr float quiet_NaN() noexcept
|
---|
| 232 | {
|
---|
| 233 | // TODO: implement
|
---|
| 234 | return 0.f;
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | static constexpr float signaling_NaN() noexcept
|
---|
| 238 | {
|
---|
| 239 | // TODO: implement
|
---|
| 240 | return 0.f;
|
---|
| 241 | }
|
---|
| 242 |
|
---|
| 243 | static constexpr float denorm_min() noexcept
|
---|
| 244 | {
|
---|
| 245 | return min();
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | static constexpr bool is_iec559 = true;
|
---|
| 249 | static constexpr bool is_bounded = true;
|
---|
| 250 | static constexpr bool is_modulo = false;
|
---|
| 251 |
|
---|
| 252 | static constexpr bool traps = true;
|
---|
| 253 | static constexpr bool tinyness_before = true;
|
---|
| 254 |
|
---|
| 255 | static constexpr float_round_style round_style = round_to_nearest;
|
---|
| 256 | };
|
---|
| 257 |
|
---|
| 258 | template<>
|
---|
| 259 | class numeric_limits<bool>
|
---|
| 260 | {
|
---|
| 261 | public:
|
---|
| 262 | static constexpr bool is_specialized = true;
|
---|
| 263 |
|
---|
| 264 | static constexpr bool min() noexcept
|
---|
| 265 | {
|
---|
| 266 | return false;
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | static constexpr bool max() noexcept
|
---|
| 270 | {
|
---|
| 271 | return true;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | static constexpr bool lowest() noexcept
|
---|
| 275 | {
|
---|
| 276 | return false;
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | static constexpr int digits = 1;
|
---|
| 280 | static constexpr int digits10 = 0;
|
---|
| 281 | static constexpr int max_digits10 = 0;
|
---|
| 282 |
|
---|
| 283 | static constexpr bool is_signed = false;
|
---|
| 284 | static constexpr bool is_integer = true;
|
---|
| 285 | static constexpr bool is_exact = true;
|
---|
| 286 |
|
---|
| 287 | static constexpr int radix = 2;
|
---|
| 288 |
|
---|
| 289 | static constexpr bool epsilon() noexcept
|
---|
| 290 | {
|
---|
| 291 | return 0;
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | static constexpr bool round_error() noexcept
|
---|
| 295 | {
|
---|
| 296 | return 0;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 | static constexpr int min_exponent = 0;
|
---|
| 300 | static constexpr int min_exponent10 = 0;
|
---|
| 301 | static constexpr int max_exponent = 0;
|
---|
| 302 | static constexpr int max_exponent10 = 0;
|
---|
| 303 |
|
---|
| 304 | static constexpr bool has_infinity = false;
|
---|
| 305 | static constexpr bool has_quiet_NaN = false;
|
---|
| 306 | static constexpr bool has_signaling_NaN = false;
|
---|
| 307 |
|
---|
| 308 | static constexpr float_denorm_style has_denorm = denorm_absent;
|
---|
| 309 | static constexpr bool has_denorm_loss = false;
|
---|
| 310 |
|
---|
| 311 | static constexpr bool infinity() noexcept
|
---|
| 312 | {
|
---|
| 313 | return 0;
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | static constexpr bool quiet_NaN() noexcept
|
---|
| 317 | {
|
---|
| 318 | return 0;
|
---|
| 319 | }
|
---|
| 320 |
|
---|
| 321 | static constexpr bool signaling_NaN() noexcept
|
---|
| 322 | {
|
---|
| 323 | return 0;
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | static constexpr bool denorm_min() noexcept
|
---|
| 327 | {
|
---|
| 328 | return 0;
|
---|
| 329 | }
|
---|
| 330 |
|
---|
| 331 | static constexpr bool is_iec559 = false;
|
---|
| 332 | static constexpr bool is_bounded = true;
|
---|
| 333 | static constexpr bool is_modulo = false;
|
---|
| 334 |
|
---|
| 335 | static constexpr bool traps = false;
|
---|
| 336 | static constexpr bool tinyness_before = false;
|
---|
| 337 |
|
---|
| 338 | static constexpr float_round_style round_style = round_toward_zero;
|
---|
| 339 | };
|
---|
| 340 |
|
---|
| 341 | /**
|
---|
| 342 | * Note: Because of the limited state of limit.h, we define only
|
---|
| 343 | * the most basic properties of the most basic types (that are likely
|
---|
| 344 | * to be used in a program that is being ported to HelenOS).
|
---|
| 345 | */
|
---|
| 346 |
|
---|
| 347 | template<>
|
---|
[092a436] | 348 | class numeric_limits<char>: public aux::numeric_limits<char>
|
---|
[a3067af] | 349 | {
|
---|
| 350 | public:
|
---|
| 351 | static constexpr bool is_specialized = true;
|
---|
| 352 |
|
---|
[980ad03] | 353 | static constexpr int digits = sizeof(char) * 8;
|
---|
| 354 |
|
---|
[092a436] | 355 | static constexpr char max()
|
---|
[a3067af] | 356 | {
|
---|
[092a436] | 357 | return CHAR_MAX;
|
---|
[a3067af] | 358 | }
|
---|
| 359 |
|
---|
[092a436] | 360 | static constexpr char min()
|
---|
[a3067af] | 361 | {
|
---|
[092a436] | 362 | return CHAR_MIN;
|
---|
[a3067af] | 363 | }
|
---|
[4e68727] | 364 |
|
---|
[092a436] | 365 | static constexpr char lowest()
|
---|
[4e68727] | 366 | {
|
---|
| 367 | return min();
|
---|
| 368 | }
|
---|
[a3067af] | 369 | };
|
---|
| 370 |
|
---|
| 371 | template<>
|
---|
[092a436] | 372 | class numeric_limits<signed char>: public aux::numeric_limits<signed char>
|
---|
[a3067af] | 373 | {
|
---|
| 374 | public:
|
---|
| 375 | static constexpr bool is_specialized = true;
|
---|
| 376 |
|
---|
[980ad03] | 377 | static constexpr int digits = sizeof(signed char) * 8 - 1;
|
---|
| 378 |
|
---|
[092a436] | 379 | static constexpr signed char max()
|
---|
[a3067af] | 380 | {
|
---|
[092a436] | 381 | return SCHAR_MAX;
|
---|
[a3067af] | 382 | }
|
---|
| 383 |
|
---|
[092a436] | 384 | static constexpr signed char min()
|
---|
[a3067af] | 385 | {
|
---|
[092a436] | 386 | return SCHAR_MIN;
|
---|
[a3067af] | 387 | }
|
---|
[4e68727] | 388 |
|
---|
[092a436] | 389 | static constexpr signed char lowest()
|
---|
[4e68727] | 390 | {
|
---|
| 391 | return min();
|
---|
| 392 | }
|
---|
[a3067af] | 393 | };
|
---|
| 394 |
|
---|
| 395 | template<>
|
---|
[092a436] | 396 | class numeric_limits<short>: public aux::numeric_limits<short>
|
---|
[a3067af] | 397 | {
|
---|
| 398 | public:
|
---|
| 399 | static constexpr bool is_specialized = true;
|
---|
| 400 |
|
---|
[980ad03] | 401 | static constexpr int digits = sizeof(short) * 8 - 1;
|
---|
| 402 |
|
---|
[092a436] | 403 | static constexpr short max()
|
---|
[a3067af] | 404 | {
|
---|
[092a436] | 405 | return SHRT_MAX;
|
---|
[a3067af] | 406 | }
|
---|
| 407 |
|
---|
[092a436] | 408 | static constexpr short min()
|
---|
[a3067af] | 409 | {
|
---|
[092a436] | 410 | return SHRT_MIN;
|
---|
[a3067af] | 411 | }
|
---|
[4e68727] | 412 |
|
---|
[092a436] | 413 | static constexpr short lowest()
|
---|
[4e68727] | 414 | {
|
---|
| 415 | return min();
|
---|
| 416 | }
|
---|
[a3067af] | 417 | };
|
---|
| 418 |
|
---|
| 419 | template<>
|
---|
[092a436] | 420 | class numeric_limits<int>: public aux::numeric_limits<int>
|
---|
[a3067af] | 421 | {
|
---|
| 422 | public:
|
---|
| 423 | static constexpr bool is_specialized = true;
|
---|
| 424 |
|
---|
[980ad03] | 425 | static constexpr int digits = sizeof(int) * 8 - 1;
|
---|
| 426 |
|
---|
[092a436] | 427 | static constexpr int max()
|
---|
[a3067af] | 428 | {
|
---|
[092a436] | 429 | return INT_MAX;
|
---|
[a3067af] | 430 | }
|
---|
| 431 |
|
---|
[092a436] | 432 | static constexpr int min()
|
---|
[a3067af] | 433 | {
|
---|
[092a436] | 434 | return INT_MIN;
|
---|
[a3067af] | 435 | }
|
---|
[4e68727] | 436 |
|
---|
[092a436] | 437 | static constexpr int lowest()
|
---|
[4e68727] | 438 | {
|
---|
| 439 | return min();
|
---|
| 440 | }
|
---|
[a3067af] | 441 | };
|
---|
| 442 |
|
---|
| 443 | template<>
|
---|
[092a436] | 444 | class numeric_limits<long>: public aux::numeric_limits<long>
|
---|
[a3067af] | 445 | {
|
---|
| 446 | public:
|
---|
| 447 | static constexpr bool is_specialized = true;
|
---|
| 448 |
|
---|
[980ad03] | 449 | static constexpr int digits = sizeof(long) * 8 - 1;
|
---|
| 450 |
|
---|
[092a436] | 451 | static constexpr long max()
|
---|
[a3067af] | 452 | {
|
---|
[092a436] | 453 | return LONG_MAX;
|
---|
[a3067af] | 454 | }
|
---|
| 455 |
|
---|
[092a436] | 456 | static constexpr long min()
|
---|
[a3067af] | 457 | {
|
---|
[092a436] | 458 | return LONG_MIN;
|
---|
[a3067af] | 459 | }
|
---|
[4e68727] | 460 |
|
---|
[092a436] | 461 | static constexpr long lowest()
|
---|
[4e68727] | 462 | {
|
---|
| 463 | return min();
|
---|
| 464 | }
|
---|
[a3067af] | 465 | };
|
---|
| 466 |
|
---|
| 467 | template<>
|
---|
[092a436] | 468 | class numeric_limits<long long>: public aux::numeric_limits<long long>
|
---|
[a3067af] | 469 | {
|
---|
| 470 | public:
|
---|
| 471 | static constexpr bool is_specialized = true;
|
---|
| 472 |
|
---|
[980ad03] | 473 | static constexpr int digits = sizeof(long long) * 8 - 1;
|
---|
| 474 |
|
---|
[092a436] | 475 | static constexpr long long max()
|
---|
[a3067af] | 476 | {
|
---|
[092a436] | 477 | return LLONG_MAX;
|
---|
[a3067af] | 478 | }
|
---|
| 479 |
|
---|
[092a436] | 480 | static constexpr long long min()
|
---|
[a3067af] | 481 | {
|
---|
[092a436] | 482 | return LLONG_MIN;
|
---|
[a3067af] | 483 | }
|
---|
[4e68727] | 484 |
|
---|
[092a436] | 485 | static constexpr long long lowest()
|
---|
[4e68727] | 486 | {
|
---|
| 487 | return min();
|
---|
| 488 | }
|
---|
[a3067af] | 489 | };
|
---|
| 490 |
|
---|
| 491 | template<>
|
---|
[092a436] | 492 | class numeric_limits<unsigned char>: public aux::numeric_limits<unsigned char>
|
---|
[a3067af] | 493 | {
|
---|
| 494 | public:
|
---|
| 495 | static constexpr bool is_specialized = true;
|
---|
| 496 |
|
---|
[980ad03] | 497 | static constexpr int digits = sizeof(unsigned char) * 8;
|
---|
| 498 |
|
---|
[092a436] | 499 | static constexpr unsigned char max()
|
---|
[a3067af] | 500 | {
|
---|
[092a436] | 501 | return SCHAR_MAX;
|
---|
[a3067af] | 502 | }
|
---|
| 503 |
|
---|
[092a436] | 504 | static constexpr unsigned char min()
|
---|
[a3067af] | 505 | {
|
---|
[092a436] | 506 | return SCHAR_MIN;
|
---|
[a3067af] | 507 | }
|
---|
[4e68727] | 508 |
|
---|
[092a436] | 509 | static constexpr unsigned char lowest()
|
---|
[4e68727] | 510 | {
|
---|
| 511 | return min();
|
---|
| 512 | }
|
---|
[a3067af] | 513 | };
|
---|
| 514 |
|
---|
| 515 | template<>
|
---|
[092a436] | 516 | class numeric_limits<unsigned short>: public aux::numeric_limits<unsigned short>
|
---|
[a3067af] | 517 | {
|
---|
| 518 | public:
|
---|
| 519 | static constexpr bool is_specialized = true;
|
---|
| 520 |
|
---|
[980ad03] | 521 | static constexpr int digits = sizeof(unsigned short) * 8;
|
---|
| 522 |
|
---|
[092a436] | 523 | static constexpr unsigned short max()
|
---|
[a3067af] | 524 | {
|
---|
[092a436] | 525 | return USHRT_MAX;
|
---|
[a3067af] | 526 | }
|
---|
| 527 |
|
---|
[092a436] | 528 | static constexpr unsigned short min()
|
---|
[a3067af] | 529 | {
|
---|
[bc56f30] | 530 | return 0;
|
---|
[a3067af] | 531 | }
|
---|
[4e68727] | 532 |
|
---|
[092a436] | 533 | static constexpr unsigned short lowest()
|
---|
| 534 | {
|
---|
| 535 | return min();
|
---|
| 536 | }
|
---|
| 537 | };
|
---|
| 538 |
|
---|
| 539 | template<>
|
---|
| 540 | class numeric_limits<unsigned int>: public aux::numeric_limits<unsigned int>
|
---|
| 541 | {
|
---|
| 542 | public:
|
---|
| 543 | static constexpr bool is_specialized = true;
|
---|
| 544 |
|
---|
[980ad03] | 545 | static constexpr int digits = sizeof(unsigned int) * 8;
|
---|
| 546 |
|
---|
[092a436] | 547 | static constexpr unsigned int max()
|
---|
| 548 | {
|
---|
| 549 | return UINT_MAX;
|
---|
| 550 | }
|
---|
| 551 |
|
---|
| 552 | static constexpr unsigned int min()
|
---|
| 553 | {
|
---|
[bc56f30] | 554 | return 0;
|
---|
[092a436] | 555 | }
|
---|
| 556 |
|
---|
| 557 | static constexpr unsigned int lowest()
|
---|
| 558 | {
|
---|
| 559 | return min();
|
---|
| 560 | }
|
---|
| 561 | };
|
---|
| 562 |
|
---|
| 563 | template<>
|
---|
| 564 | class numeric_limits<unsigned long>: public aux::numeric_limits<unsigned long>
|
---|
| 565 | {
|
---|
| 566 | public:
|
---|
| 567 | static constexpr bool is_specialized = true;
|
---|
| 568 |
|
---|
[980ad03] | 569 | static constexpr int digits = sizeof(unsigned long) * 8;
|
---|
| 570 |
|
---|
[092a436] | 571 | static constexpr unsigned long max()
|
---|
| 572 | {
|
---|
| 573 | return ULONG_MAX;
|
---|
| 574 | }
|
---|
| 575 |
|
---|
| 576 | static constexpr unsigned long min()
|
---|
| 577 | {
|
---|
[bc56f30] | 578 | return 0;
|
---|
[092a436] | 579 | }
|
---|
| 580 |
|
---|
| 581 | static constexpr unsigned long lowest()
|
---|
| 582 | {
|
---|
| 583 | return min();
|
---|
| 584 | }
|
---|
| 585 | };
|
---|
| 586 |
|
---|
| 587 | template<>
|
---|
| 588 | class numeric_limits<unsigned long long>: public aux::numeric_limits<unsigned long long>
|
---|
| 589 | {
|
---|
| 590 | public:
|
---|
| 591 | static constexpr bool is_specialized = true;
|
---|
| 592 |
|
---|
[980ad03] | 593 | static constexpr int digits = sizeof(unsigned long long) * 8;
|
---|
| 594 |
|
---|
[092a436] | 595 | static constexpr unsigned long long max()
|
---|
| 596 | {
|
---|
| 597 | return ULLONG_MAX;
|
---|
| 598 | }
|
---|
| 599 |
|
---|
| 600 | static constexpr unsigned long long min()
|
---|
| 601 | {
|
---|
[bc56f30] | 602 | return 0;
|
---|
[092a436] | 603 | }
|
---|
| 604 |
|
---|
| 605 | static constexpr unsigned long long lowest()
|
---|
[4e68727] | 606 | {
|
---|
| 607 | return min();
|
---|
| 608 | }
|
---|
[a3067af] | 609 | };
|
---|
| 610 |
|
---|
| 611 | template<>
|
---|
| 612 | class numeric_limits<double>: public aux::numeric_limits<double>
|
---|
| 613 | {
|
---|
| 614 | public:
|
---|
| 615 | // TODO: implement
|
---|
[980ad03] | 616 | static constexpr int digits = sizeof(short) * 8 - 1;
|
---|
[a3067af] | 617 | };
|
---|
| 618 |
|
---|
| 619 | template<>
|
---|
| 620 | class numeric_limits<long double>: public aux::numeric_limits<long double>
|
---|
| 621 | {
|
---|
| 622 | public:
|
---|
| 623 | // TODO: implement
|
---|
| 624 | };
|
---|
| 625 | }
|
---|
| 626 |
|
---|
| 627 | #endif
|
---|