blob: cd55d9b3d124d12b0edcf0ff839b7301730e8e9b [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
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 Thompson3d613fd2013-10-15 15:39:04 -070011#ifndef NDNBOOST_LIMITS
12#define NDNBOOST_LIMITS
Jeff Thompsona28eed82013-08-22 16:21:10 -070013
14#include <ndnboost/config.hpp>
15
Jeff Thompson3d613fd2013-10-15 15:39:04 -070016#ifdef NDNBOOST_NO_LIMITS
Jeff Thompsona28eed82013-08-22 16:21:10 -070017# error "There is no std::numeric_limits suppport available."
18#else
19# include <limits>
20#endif
21
Jeff Thompson3d613fd2013-10-15 15:39:04 -070022#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 Thompsona28eed82013-08-22 16:21:10 -070024// Add missing specializations for numeric_limits:
Jeff Thompson3d613fd2013-10-15 15:39:04 -070025#ifdef NDNBOOST_HAS_MS_INT64
26# define NDNBOOST_LLT __int64
27# define NDNBOOST_ULLT unsigned __int64
Jeff Thompsona28eed82013-08-22 16:21:10 -070028#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070029# define NDNBOOST_LLT ::ndnboost::long_long_type
30# define NDNBOOST_ULLT ::ndnboost::ulong_long_type
Jeff Thompsona28eed82013-08-22 16:21:10 -070031#endif
32
33#include <climits> // for CHAR_BIT
34
35namespace std
36{
37 template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070038 class numeric_limits<NDNBOOST_LLT>
Jeff Thompsona28eed82013-08-22 16:21:10 -070039 {
40 public:
41
Jeff Thompson3d613fd2013-10-15 15:39:04 -070042 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 Thompsona28eed82013-08-22 16:21:10 -070046#elif defined(LLONG_MAX)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070047 static NDNBOOST_LLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return LLONG_MIN; }
48 static NDNBOOST_LLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return LLONG_MAX; }
Jeff Thompsona28eed82013-08-22 16:21:10 -070049#elif defined(LONGLONG_MAX)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070050 static NDNBOOST_LLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return LONGLONG_MIN; }
51 static NDNBOOST_LLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return LONGLONG_MAX; }
Jeff Thompsona28eed82013-08-22 16:21:10 -070052#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070053 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 Thompsona28eed82013-08-22 16:21:10 -070055#endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070056 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 Thompsona28eed82013-08-22 16:21:10 -070064
Jeff Thompson3d613fd2013-10-15 15:39:04 -070065 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 Thompsona28eed82013-08-22 16:21:10 -070069
Jeff Thompson3d613fd2013-10-15 15:39:04 -070070 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 Thompsona28eed82013-08-22 16:21:10 -070079
Jeff Thompson3d613fd2013-10-15 15:39:04 -070080 NDNBOOST_STATIC_CONSTANT(bool, is_iec559 = false);
81 NDNBOOST_STATIC_CONSTANT(bool, is_bounded = true);
82 NDNBOOST_STATIC_CONSTANT(bool, is_modulo = true);
Jeff Thompsona28eed82013-08-22 16:21:10 -070083
Jeff Thompson3d613fd2013-10-15 15:39:04 -070084 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 Thompsona28eed82013-08-22 16:21:10 -070087
88 };
89
90 template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070091 class numeric_limits<NDNBOOST_ULLT>
Jeff Thompsona28eed82013-08-22 16:21:10 -070092 {
93 public:
94
Jeff Thompson3d613fd2013-10-15 15:39:04 -070095 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 Thompsona28eed82013-08-22 16:21:10 -070099#elif defined(ULLONG_MAX) && defined(ULLONG_MIN)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700100 static NDNBOOST_ULLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MIN; }
101 static NDNBOOST_ULLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MAX; }
Jeff Thompsona28eed82013-08-22 16:21:10 -0700102#elif defined(ULONGLONG_MAX) && defined(ULONGLONG_MIN)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700103 static NDNBOOST_ULLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MIN; }
104 static NDNBOOST_ULLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MAX; }
Jeff Thompsona28eed82013-08-22 16:21:10 -0700105#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700106 static NDNBOOST_ULLT min NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0uLL; }
107 static NDNBOOST_ULLT max NDNBOOST_PREVENT_MACRO_SUBSTITUTION (){ return ~0uLL; }
Jeff Thompsona28eed82013-08-22 16:21:10 -0700108#endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700109 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 Thompsona28eed82013-08-22 16:21:10 -0700117
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700118 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 Thompsona28eed82013-08-22 16:21:10 -0700122
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700123 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 Thompsona28eed82013-08-22 16:21:10 -0700132
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700133 NDNBOOST_STATIC_CONSTANT(bool, is_iec559 = false);
134 NDNBOOST_STATIC_CONSTANT(bool, is_bounded = true);
135 NDNBOOST_STATIC_CONSTANT(bool, is_modulo = true);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700136
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700137 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 Thompsona28eed82013-08-22 16:21:10 -0700140
141 };
142}
143#endif
144
145#endif
146