mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-10 05:59:30 +08:00
functional_hash.h (hash<long double>::operator()(long double)): Only declare.
2007-11-20 Paolo Carlini <pcarlini@suse.de> * include/tr1_impl/functional_hash.h (hash<long double>::operator()(long double)): Only declare. * src/hash.cc: Define here. * config/abi/pre/gnu.ver: Adjust exports. * include/tr1/functional: Do not include <cmath>. * include/std/functional: Likewise. * include/std/functional: Include <new>. From-SVN: r130312
This commit is contained in:
parent
7ef249e59f
commit
a0ba4e53fd
@ -1,3 +1,14 @@
|
||||
2007-11-20 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/tr1_impl/functional_hash.h
|
||||
(hash<long double>::operator()(long double)): Only declare.
|
||||
* src/hash.cc: Define here.
|
||||
* config/abi/pre/gnu.ver: Adjust exports.
|
||||
* include/tr1/functional: Do not include <cmath>.
|
||||
* include/std/functional: Likewise.
|
||||
|
||||
* include/std/functional: Include <new>.
|
||||
|
||||
2007-11-18 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/tr1/type_traits (_DEFINE_SPEC_BODY): Remove.
|
||||
|
@ -770,12 +770,14 @@ GLIBCXX_3.4.10 {
|
||||
_ZNKSt3tr14hashIRKSsEclES2_;
|
||||
_ZNKSt3tr14hashISbIwSt11char_traitsIwESaIwEEEclES4_;
|
||||
_ZNKSt3tr14hashISsEclESs;
|
||||
_ZNKSt3tr14hashIeEclEe;
|
||||
|
||||
_ZNKSt4hashIRKSbIwSt11char_traitsIwESaIwEEEclES5_;
|
||||
_ZNKSt4hashIRKSsEclES1_;
|
||||
_ZNKSt4hashISbIwSt11char_traitsIwESaIwEEEclES3_;
|
||||
_ZNKSt4hashISsEclESs;
|
||||
_ZNKSt4hashISt10error_codeEclES0_;
|
||||
_ZNKSt4hashIeEclEe;
|
||||
|
||||
# for parallel mode
|
||||
_ZNSt9__cxx199815_List_node_base4hook*;
|
||||
|
@ -58,8 +58,8 @@
|
||||
# if defined(_GLIBCXX_INCLUDE_AS_TR1)
|
||||
# error C++0x header cannot be included from TR1 header
|
||||
# endif
|
||||
# include <cmath>
|
||||
# include <typeinfo>
|
||||
# include <new>
|
||||
# include <tuple>
|
||||
# include <type_traits>
|
||||
# include <bits/stringfwd.h>
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <bits/c++config.h>
|
||||
#include <bits/stl_function.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <typeinfo>
|
||||
#include <new>
|
||||
#include <tr1/tuple>
|
||||
|
@ -155,34 +155,9 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
return __result;
|
||||
};
|
||||
|
||||
// For long double, careful with random padding bits (e.g., on x86,
|
||||
// 10 bytes -> 12 bytes) and resort to frexp.
|
||||
template<>
|
||||
inline size_t
|
||||
hash<long double>::operator()(long double __val) const
|
||||
{
|
||||
size_t __result = 0;
|
||||
|
||||
int __exponent;
|
||||
__val = std::frexp(__val, &__exponent);
|
||||
__val = __val < 0.0l ? -(__val + 0.5l) : __val;
|
||||
|
||||
const long double __mult =
|
||||
__gnu_cxx::__numeric_traits<size_t>::__max + 1.0l;
|
||||
__val *= __mult;
|
||||
|
||||
// Try to use all the bits of the mantissa (really necessary only
|
||||
// on 32-bit targets, at least for 80-bit floating point formats).
|
||||
const size_t __hibits = (size_t)__val;
|
||||
__val = (__val - (long double)__hibits) * __mult;
|
||||
|
||||
const size_t __coeff =
|
||||
__gnu_cxx::__numeric_traits<size_t>::__max / __LDBL_MAX_EXP__;
|
||||
|
||||
__result = __hibits + (size_t)__val + __coeff * __exponent;
|
||||
|
||||
return __result;
|
||||
};
|
||||
size_t
|
||||
hash<long double>::operator()(long double __val) const;
|
||||
|
||||
// Explicit specialization of member operator for types that are not builtin.
|
||||
template<>
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
#include <functional>
|
||||
@ -45,6 +46,35 @@ namespace std
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
|
||||
// For long double, careful with random padding bits (e.g., on x86,
|
||||
// 10 bytes -> 12 bytes) and resort to frexp.
|
||||
template<>
|
||||
size_t
|
||||
hash<long double>::operator()(long double __val) const
|
||||
{
|
||||
size_t __result = 0;
|
||||
|
||||
int __exponent;
|
||||
__val = std::frexp(__val, &__exponent);
|
||||
__val = __val < 0.0l ? -(__val + 0.5l) : __val;
|
||||
|
||||
const long double __mult =
|
||||
__gnu_cxx::__numeric_traits<size_t>::__max + 1.0l;
|
||||
__val *= __mult;
|
||||
|
||||
// Try to use all the bits of the mantissa (really necessary only
|
||||
// on 32-bit targets, at least for 80-bit floating point formats).
|
||||
const size_t __hibits = (size_t)__val;
|
||||
__val = (__val - (long double)__hibits) * __mult;
|
||||
|
||||
const size_t __coeff =
|
||||
__gnu_cxx::__numeric_traits<size_t>::__max / __LDBL_MAX_EXP__;
|
||||
|
||||
__result = __hibits + (size_t)__val + __coeff * __exponent;
|
||||
|
||||
return __result;
|
||||
};
|
||||
|
||||
template<>
|
||||
size_t
|
||||
hash<string>::operator()(string __s) const
|
||||
|
Loading…
Reference in New Issue
Block a user