Commit 5d64ee19 by Paolo Carlini Committed by Paolo Carlini

functional_hash.h (__hash_base): Add.

2010-09-22  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/functional_hash.h (__hash_base): Add.
	(hash): Derive from __hash_base instead.
	* include/debug/bitset (hash): Likewise.
	* include/debug/vector (hash): Likewise.
	* include/std/system_error (hash): Likewise.
	* include/std/thread (hash): Likewise.
	* include/std/bitset (hash): Likewise.
	* include/profile/bitset (hash): Likewise.
	* include/profile/vector (hash): Likewise.
	* include/bits/basic_string.h (hash): Likewise.
	* include/bits/stl_bvector.h (hash): Likewise.
	* include/std/typeindex (hash): Do not derive from unary_function,
	add result_type and argument_type typedefs; trim includes.

From-SVN: r164528
parent 1cf2589d
2010-09-22 Paolo Carlini <paolo.carlini@oracle.com> 2010-09-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/functional_hash.h (__hash_base): Add.
(hash): Derive from __hash_base instead.
* include/debug/bitset (hash): Likewise.
* include/debug/vector (hash): Likewise.
* include/std/system_error (hash): Likewise.
* include/std/thread (hash): Likewise.
* include/std/bitset (hash): Likewise.
* include/profile/bitset (hash): Likewise.
* include/profile/vector (hash): Likewise.
* include/bits/basic_string.h (hash): Likewise.
* include/bits/stl_bvector.h (hash): Likewise.
* include/std/typeindex (hash): Do not derive from unary_function,
add result_type and argument_type typedefs; trim includes.
2010-09-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/typeindex: New. * include/std/typeindex: New.
* include/Makefile.am: Add. * include/Makefile.am: Add.
* include/Makefile.in: Regenerate. * include/Makefile.in: Regenerate.
......
...@@ -2925,7 +2925,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -2925,7 +2925,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// std::hash specialization for string. /// std::hash specialization for string.
template<> template<>
struct hash<string> struct hash<string>
: public std::unary_function<string, size_t> : public __hash_base<size_t, string>
{ {
size_t size_t
operator()(const string& __s) const operator()(const string& __s) const
...@@ -2936,7 +2936,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -2936,7 +2936,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// std::hash specialization for wstring. /// std::hash specialization for wstring.
template<> template<>
struct hash<wstring> struct hash<wstring>
: public std::unary_function<wstring, size_t> : public __hash_base<size_t, wstring>
{ {
size_t size_t
operator()(const wstring& __s) const operator()(const wstring& __s) const
...@@ -2950,7 +2950,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -2950,7 +2950,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// std::hash specialization for u16string. /// std::hash specialization for u16string.
template<> template<>
struct hash<u16string> struct hash<u16string>
: public std::unary_function<u16string, size_t> : public __hash_base<size_t, u16string>
{ {
size_t size_t
operator()(const u16string& __s) const operator()(const u16string& __s) const
...@@ -2961,7 +2961,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -2961,7 +2961,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// std::hash specialization for u32string. /// std::hash specialization for u32string.
template<> template<>
struct hash<u32string> struct hash<u32string>
: public std::unary_function<u32string, size_t> : public __hash_base<size_t, u32string>
{ {
size_t size_t
operator()(const u32string& __s) const operator()(const u32string& __s) const
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#pragma GCC system_header #pragma GCC system_header
#include <bits/c++config.h> #include <bits/c++config.h>
#include <bits/stl_function.h>
namespace std namespace std
{ {
...@@ -45,9 +44,16 @@ namespace std ...@@ -45,9 +44,16 @@ namespace std
* @{ * @{
*/ */
template<typename _Result, typename _Arg>
struct __hash_base
{
typedef _Result result_type;
typedef _Arg argument_type;
};
/// Primary class template hash. /// Primary class template hash.
template<typename _Tp> template<typename _Tp>
struct hash : public std::unary_function<_Tp, size_t> struct hash : public __hash_base<size_t, _Tp>
{ {
size_t size_t
operator()(_Tp __val) const; operator()(_Tp __val) const;
...@@ -55,7 +61,7 @@ namespace std ...@@ -55,7 +61,7 @@ namespace std
/// Partial specializations for pointer types. /// Partial specializations for pointer types.
template<typename _Tp> template<typename _Tp>
struct hash<_Tp*> : public std::unary_function<_Tp*, size_t> struct hash<_Tp*> : public __hash_base<size_t, _Tp*>
{ {
size_t size_t
operator()(_Tp* __p) const operator()(_Tp* __p) const
......
...@@ -1038,7 +1038,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1038,7 +1038,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// std::hash specialization for vector<bool>. /// std::hash specialization for vector<bool>.
template<typename _Alloc> template<typename _Alloc>
struct hash<_GLIBCXX_STD_D::vector<bool, _Alloc>> struct hash<_GLIBCXX_STD_D::vector<bool, _Alloc>>
: public std::unary_function<_GLIBCXX_STD_D::vector<bool, _Alloc>, size_t> : public __hash_base<size_t, _GLIBCXX_STD_D::vector<bool, _Alloc>>
{ {
size_t size_t
operator()(const _GLIBCXX_STD_D::vector<bool, _Alloc>& __b) const; operator()(const _GLIBCXX_STD_D::vector<bool, _Alloc>& __b) const;
......
...@@ -385,7 +385,7 @@ namespace __debug ...@@ -385,7 +385,7 @@ namespace __debug
/// std::hash specialization for bitset. /// std::hash specialization for bitset.
template<size_t _Nb> template<size_t _Nb>
struct hash<__debug::bitset<_Nb>> struct hash<__debug::bitset<_Nb>>
: public std::unary_function<__debug::bitset<_Nb>, size_t> : public __hash_base<size_t, __debug::bitset<_Nb>>
{ {
size_t size_t
operator()(const __debug::bitset<_Nb>& __b) const operator()(const __debug::bitset<_Nb>& __b) const
......
...@@ -584,7 +584,7 @@ namespace __debug ...@@ -584,7 +584,7 @@ namespace __debug
/// std::hash specialization for vector<bool>. /// std::hash specialization for vector<bool>.
template<typename _Alloc> template<typename _Alloc>
struct hash<__debug::vector<bool, _Alloc>> struct hash<__debug::vector<bool, _Alloc>>
: public std::unary_function<__debug::vector<bool, _Alloc>, size_t> : public __hash_base<size_t, __debug::vector<bool, _Alloc>>
{ {
size_t size_t
operator()(const __debug::vector<bool, _Alloc>& __b) const operator()(const __debug::vector<bool, _Alloc>& __b) const
......
...@@ -359,7 +359,7 @@ namespace __profile ...@@ -359,7 +359,7 @@ namespace __profile
/// std::hash specialization for bitset. /// std::hash specialization for bitset.
template<size_t _Nb> template<size_t _Nb>
struct hash<__profile::bitset<_Nb>> struct hash<__profile::bitset<_Nb>>
: public std::unary_function<__profile::bitset<_Nb>, size_t> : public __hash_base<size_t, __profile::bitset<_Nb>>
{ {
size_t size_t
operator()(const __profile::bitset<_Nb>& __b) const operator()(const __profile::bitset<_Nb>& __b) const
......
...@@ -505,7 +505,7 @@ namespace __profile ...@@ -505,7 +505,7 @@ namespace __profile
/// std::hash specialization for vector<bool>. /// std::hash specialization for vector<bool>.
template<typename _Alloc> template<typename _Alloc>
struct hash<__profile::vector<bool, _Alloc>> struct hash<__profile::vector<bool, _Alloc>>
: public std::unary_function<__profile::vector<bool, _Alloc>, size_t> : public __hash_base<size_t, __profile::vector<bool, _Alloc>>
{ {
size_t size_t
operator()(const __profile::vector<bool, _Alloc>& __b) const operator()(const __profile::vector<bool, _Alloc>& __b) const
......
...@@ -1495,7 +1495,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1495,7 +1495,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// std::hash specialization for bitset. /// std::hash specialization for bitset.
template<size_t _Nb> template<size_t _Nb>
struct hash<_GLIBCXX_STD_D::bitset<_Nb>> struct hash<_GLIBCXX_STD_D::bitset<_Nb>>
: public std::unary_function<_GLIBCXX_STD_D::bitset<_Nb>, size_t> : public __hash_base<size_t, _GLIBCXX_STD_D::bitset<_Nb>>
{ {
size_t size_t
operator()(const _GLIBCXX_STD_D::bitset<_Nb>& __b) const operator()(const _GLIBCXX_STD_D::bitset<_Nb>& __b) const
...@@ -1507,7 +1507,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1507,7 +1507,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<> template<>
struct hash<_GLIBCXX_STD_D::bitset<0>> struct hash<_GLIBCXX_STD_D::bitset<0>>
: public std::unary_function<_GLIBCXX_STD_D::bitset<0>, size_t> : public __hash_base<size_t, _GLIBCXX_STD_D::bitset<0>>
{ {
size_t size_t
operator()(const _GLIBCXX_STD_D::bitset<0>&) const operator()(const _GLIBCXX_STD_D::bitset<0>&) const
......
...@@ -353,7 +353,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -353,7 +353,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// std::hash specialization for error_code. /// std::hash specialization for error_code.
template<> template<>
struct hash<error_code> struct hash<error_code>
: public std::unary_function<error_code, size_t> : public __hash_base<size_t, error_code>
{ {
size_t size_t
operator()(const error_code& __e) const operator()(const error_code& __e) const
......
...@@ -56,9 +56,6 @@ namespace std ...@@ -56,9 +56,6 @@ namespace std
* @{ * @{
*/ */
template<typename _Tp>
struct hash;
/// thread /// thread
class thread class thread
{ {
...@@ -224,7 +221,7 @@ namespace std ...@@ -224,7 +221,7 @@ namespace std
/// std::hash specialization for thread::id. /// std::hash specialization for thread::id.
template<> template<>
struct hash<thread::id> struct hash<thread::id>
: public std::unary_function<thread::id, size_t> : public __hash_base<size_t, thread::id>
{ {
size_t size_t
operator()(const thread::id& __id) const operator()(const thread::id& __id) const
......
...@@ -35,9 +35,7 @@ ...@@ -35,9 +35,7 @@
# include <bits/c++0x_warning.h> # include <bits/c++0x_warning.h>
#else #else
#include <bits/c++config.h>
#include <typeinfo> #include <typeinfo>
#include <bits/stl_function.h> // For unary_function
namespace std namespace std
{ {
...@@ -92,8 +90,10 @@ namespace std ...@@ -92,8 +90,10 @@ namespace std
/// std::hash specialization for type_index. /// std::hash specialization for type_index.
template<> template<>
struct hash<type_index> struct hash<type_index>
: public std::unary_function<type_index, size_t>
{ {
typedef size_t result_type;
typedef type_index argument_type;
size_t size_t
operator()(const type_index& __ti) const operator()(const type_index& __ti) const
{ return __ti.hash_code(); } { return __ti.hash_code(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment