blob: f25b3bed07f8bdc3bc69625e7a7168f4e3aa392a [file] [log] [blame]
Jeff Thompson86b6d642013-10-17 15:01:56 -07001
2// Copyright 2005-2009 Daniel James.
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5//
6// On some platforms std::limits gives incorrect values for long double.
7// This tries to work around them.
8
9#if !defined(NDNBOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER)
10#define NDNBOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER
11
12#if defined(_MSC_VER) && (_MSC_VER >= 1020)
13# pragma once
14#endif
15
16#include <ndnboost/limits.hpp>
17
18// On OpenBSD, numeric_limits is not reliable for long doubles, but
19// the macros defined in <float.h> are and support long double when STLport
20// doesn't.
21
22#if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE)
23#include <float.h>
24#endif
25
26namespace ndnboost
27{
28 namespace hash_detail
29 {
30 template <class T>
31 struct limits : std::numeric_limits<T> {};
32
33#if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE)
34 template <>
35 struct limits<long double>
36 : std::numeric_limits<long double>
37 {
38 static long double epsilon() {
39 return LDBL_EPSILON;
40 }
41
42 static long double (max)() {
43 return LDBL_MAX;
44 }
45
46 static long double (min)() {
47 return LDBL_MIN;
48 }
49
50 NDNBOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG);
51 NDNBOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP);
52 NDNBOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP);
53#if defined(_STLP_NO_LONG_DOUBLE)
54 NDNBOOST_STATIC_CONSTANT(int, radix = FLT_RADIX);
55#endif
56 };
57#endif // __OpenBSD__
58 }
59}
60
61#endif