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