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@101
|
12 #include <boost/config.hpp>
|
Chris@101
|
13 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
14 #pragma once
|
Chris@16
|
15 #endif
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/limits.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 // On OpenBSD, numeric_limits is not reliable for long doubles, but
|
Chris@16
|
20 // the macros defined in <float.h> are and support long double when STLport
|
Chris@16
|
21 // doesn't.
|
Chris@16
|
22
|
Chris@16
|
23 #if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE)
|
Chris@16
|
24 #include <float.h>
|
Chris@16
|
25 #endif
|
Chris@16
|
26
|
Chris@16
|
27 namespace boost
|
Chris@16
|
28 {
|
Chris@16
|
29 namespace hash_detail
|
Chris@16
|
30 {
|
Chris@16
|
31 template <class T>
|
Chris@16
|
32 struct limits : std::numeric_limits<T> {};
|
Chris@16
|
33
|
Chris@16
|
34 #if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE)
|
Chris@16
|
35 template <>
|
Chris@16
|
36 struct limits<long double>
|
Chris@16
|
37 : std::numeric_limits<long double>
|
Chris@16
|
38 {
|
Chris@16
|
39 static long double epsilon() {
|
Chris@16
|
40 return LDBL_EPSILON;
|
Chris@16
|
41 }
|
Chris@16
|
42
|
Chris@16
|
43 static long double (max)() {
|
Chris@16
|
44 return LDBL_MAX;
|
Chris@16
|
45 }
|
Chris@16
|
46
|
Chris@16
|
47 static long double (min)() {
|
Chris@16
|
48 return LDBL_MIN;
|
Chris@16
|
49 }
|
Chris@16
|
50
|
Chris@16
|
51 BOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG);
|
Chris@16
|
52 BOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP);
|
Chris@16
|
53 BOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP);
|
Chris@16
|
54 #if defined(_STLP_NO_LONG_DOUBLE)
|
Chris@16
|
55 BOOST_STATIC_CONSTANT(int, radix = FLT_RADIX);
|
Chris@16
|
56 #endif
|
Chris@16
|
57 };
|
Chris@16
|
58 #endif // __OpenBSD__
|
Chris@16
|
59 }
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 #endif
|