Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // (C) Copyright John maddock 1999. |
| 3 | // (C) David Abrahams 2002. Distributed under the Boost |
| 4 | // Software License, Version 1.0. (See accompanying file |
| 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | // |
| 7 | // use this header as a workaround for missing <limits> |
| 8 | |
| 9 | // See http://www.boost.org/libs/compatibility/index.html for documentation. |
| 10 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 11 | #ifndef NDNBOOST_LIMITS |
| 12 | #define NDNBOOST_LIMITS |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 13 | |
| 14 | #include <ndnboost/config.hpp> |
| 15 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 16 | #ifdef NDNBOOST_NO_LIMITS |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 17 | # error "There is no std::numeric_limits suppport available." |
| 18 | #else |
| 19 | # include <limits> |
| 20 | #endif |
| 21 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 22 | #if (defined(NDNBOOST_HAS_LONG_LONG) && defined(NDNBOOST_NO_LONG_LONG_NUMERIC_LIMITS)) \ |
| 23 | || (defined(NDNBOOST_HAS_MS_INT64) && defined(NDNBOOST_NO_MS_INT64_NUMERIC_LIMITS)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 24 | // Add missing specializations for numeric_limits: |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 25 | #ifdef NDNBOOST_HAS_MS_INT64 |
| 26 | # define NDNBOOST_LLT __int64 |
| 27 | # define NDNBOOST_ULLT unsigned __int64 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 28 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 29 | # define NDNBOOST_LLT ::ndnboost::long_long_type |
| 30 | # define NDNBOOST_ULLT ::ndnboost::ulong_long_type |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 31 | #endif |
| 32 | |
| 33 | #include <climits> // for CHAR_BIT |
| 34 | |
| 35 | namespace std |
| 36 | { |
| 37 | template<> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 38 | class numeric_limits<NDNBOOST_LLT> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 39 | { |
| 40 | public: |
| 41 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 42 | NDNBOOST_STATIC_CONSTANT(bool, is_specialized = true); |
| 43 | #ifdef NDNBOOST_HAS_MS_INT64 |
| 44 | static NDNBOOST_LLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0x8000000000000000i64; } |
| 45 | static NDNBOOST_LLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0x7FFFFFFFFFFFFFFFi64; } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 46 | #elif defined(LLONG_MAX) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 47 | static NDNBOOST_LLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return LLONG_MIN; } |
| 48 | static NDNBOOST_LLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return LLONG_MAX; } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 49 | #elif defined(LONGLONG_MAX) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 50 | static NDNBOOST_LLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return LONGLONG_MIN; } |
| 51 | static NDNBOOST_LLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return LONGLONG_MAX; } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 52 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 53 | static NDNBOOST_LLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return 1LL << (sizeof(NDNBOOST_LLT) * CHAR_BIT - 1); } |
| 54 | static NDNBOOST_LLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ~(min)(); } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 55 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 56 | NDNBOOST_STATIC_CONSTANT(int, digits = sizeof(NDNBOOST_LLT) * CHAR_BIT -1); |
| 57 | NDNBOOST_STATIC_CONSTANT(int, digits10 = (CHAR_BIT * sizeof (NDNBOOST_LLT) - 1) * 301L / 1000); |
| 58 | NDNBOOST_STATIC_CONSTANT(bool, is_signed = true); |
| 59 | NDNBOOST_STATIC_CONSTANT(bool, is_integer = true); |
| 60 | NDNBOOST_STATIC_CONSTANT(bool, is_exact = true); |
| 61 | NDNBOOST_STATIC_CONSTANT(int, radix = 2); |
| 62 | static NDNBOOST_LLT epsilon() throw() { return 0; }; |
| 63 | static NDNBOOST_LLT round_error() throw() { return 0; }; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 64 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 65 | NDNBOOST_STATIC_CONSTANT(int, min_exponent = 0); |
| 66 | NDNBOOST_STATIC_CONSTANT(int, min_exponent10 = 0); |
| 67 | NDNBOOST_STATIC_CONSTANT(int, max_exponent = 0); |
| 68 | NDNBOOST_STATIC_CONSTANT(int, max_exponent10 = 0); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 69 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 70 | NDNBOOST_STATIC_CONSTANT(bool, has_infinity = false); |
| 71 | NDNBOOST_STATIC_CONSTANT(bool, has_quiet_NaN = false); |
| 72 | NDNBOOST_STATIC_CONSTANT(bool, has_signaling_NaN = false); |
| 73 | NDNBOOST_STATIC_CONSTANT(bool, has_denorm = false); |
| 74 | NDNBOOST_STATIC_CONSTANT(bool, has_denorm_loss = false); |
| 75 | static NDNBOOST_LLT infinity() throw() { return 0; }; |
| 76 | static NDNBOOST_LLT quiet_NaN() throw() { return 0; }; |
| 77 | static NDNBOOST_LLT signaling_NaN() throw() { return 0; }; |
| 78 | static NDNBOOST_LLT denorm_min() throw() { return 0; }; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 79 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 80 | NDNBOOST_STATIC_CONSTANT(bool, is_iec559 = false); |
| 81 | NDNBOOST_STATIC_CONSTANT(bool, is_bounded = true); |
| 82 | NDNBOOST_STATIC_CONSTANT(bool, is_modulo = true); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 83 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 84 | NDNBOOST_STATIC_CONSTANT(bool, traps = false); |
| 85 | NDNBOOST_STATIC_CONSTANT(bool, tinyness_before = false); |
| 86 | NDNBOOST_STATIC_CONSTANT(float_round_style, round_style = round_toward_zero); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 87 | |
| 88 | }; |
| 89 | |
| 90 | template<> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 91 | class numeric_limits<NDNBOOST_ULLT> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 92 | { |
| 93 | public: |
| 94 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 95 | NDNBOOST_STATIC_CONSTANT(bool, is_specialized = true); |
| 96 | #ifdef NDNBOOST_HAS_MS_INT64 |
| 97 | static NDNBOOST_ULLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0ui64; } |
| 98 | static NDNBOOST_ULLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0xFFFFFFFFFFFFFFFFui64; } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 99 | #elif defined(ULLONG_MAX) && defined(ULLONG_MIN) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 100 | static NDNBOOST_ULLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MIN; } |
| 101 | static NDNBOOST_ULLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MAX; } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 102 | #elif defined(ULONGLONG_MAX) && defined(ULONGLONG_MIN) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 103 | static NDNBOOST_ULLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MIN; } |
| 104 | static NDNBOOST_ULLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MAX; } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 105 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 106 | static NDNBOOST_ULLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0uLL; } |
| 107 | static NDNBOOST_ULLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ~0uLL; } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 108 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 109 | NDNBOOST_STATIC_CONSTANT(int, digits = sizeof(NDNBOOST_LLT) * CHAR_BIT); |
| 110 | NDNBOOST_STATIC_CONSTANT(int, digits10 = (CHAR_BIT * sizeof (NDNBOOST_LLT)) * 301L / 1000); |
| 111 | NDNBOOST_STATIC_CONSTANT(bool, is_signed = false); |
| 112 | NDNBOOST_STATIC_CONSTANT(bool, is_integer = true); |
| 113 | NDNBOOST_STATIC_CONSTANT(bool, is_exact = true); |
| 114 | NDNBOOST_STATIC_CONSTANT(int, radix = 2); |
| 115 | static NDNBOOST_ULLT epsilon() throw() { return 0; }; |
| 116 | static NDNBOOST_ULLT round_error() throw() { return 0; }; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 117 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 118 | NDNBOOST_STATIC_CONSTANT(int, min_exponent = 0); |
| 119 | NDNBOOST_STATIC_CONSTANT(int, min_exponent10 = 0); |
| 120 | NDNBOOST_STATIC_CONSTANT(int, max_exponent = 0); |
| 121 | NDNBOOST_STATIC_CONSTANT(int, max_exponent10 = 0); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 122 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 123 | NDNBOOST_STATIC_CONSTANT(bool, has_infinity = false); |
| 124 | NDNBOOST_STATIC_CONSTANT(bool, has_quiet_NaN = false); |
| 125 | NDNBOOST_STATIC_CONSTANT(bool, has_signaling_NaN = false); |
| 126 | NDNBOOST_STATIC_CONSTANT(bool, has_denorm = false); |
| 127 | NDNBOOST_STATIC_CONSTANT(bool, has_denorm_loss = false); |
| 128 | static NDNBOOST_ULLT infinity() throw() { return 0; }; |
| 129 | static NDNBOOST_ULLT quiet_NaN() throw() { return 0; }; |
| 130 | static NDNBOOST_ULLT signaling_NaN() throw() { return 0; }; |
| 131 | static NDNBOOST_ULLT denorm_min() throw() { return 0; }; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 132 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 133 | NDNBOOST_STATIC_CONSTANT(bool, is_iec559 = false); |
| 134 | NDNBOOST_STATIC_CONSTANT(bool, is_bounded = true); |
| 135 | NDNBOOST_STATIC_CONSTANT(bool, is_modulo = true); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 136 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 137 | NDNBOOST_STATIC_CONSTANT(bool, traps = false); |
| 138 | NDNBOOST_STATIC_CONSTANT(bool, tinyness_before = false); |
| 139 | NDNBOOST_STATIC_CONSTANT(float_round_style, round_style = round_toward_zero); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 140 | |
| 141 | }; |
| 142 | } |
| 143 | #endif |
| 144 | |
| 145 | #endif |
| 146 | |