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