[PATCH] Use shared_ptr<T>::element_type in hash specializations

Jonathan Wakely jwakely@redhat.com
Sat Nov 12 03:24:00 GMT 2016


Some tweaks I missed from the preparing-shared_ptr-for-arrays patch.

	* include/bits/shared_ptr.h (hash<shared_ptr<T>>): Use element_type.
	* include/bits/shared_ptr_base.h (hash<__shared_ptr<T, L>>): Likewise.

Tested powerpc64le-linux, committed to trunk.

-------------- next part --------------
commit 6b13d2ff4a8528fb663c855da0d11d5992120288
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Nov 11 05:15:54 2016 +0000

    Use shared_ptr<T>::element_type in hash specializations
    
    	* include/bits/shared_ptr.h (hash<shared_ptr<T>>): Use element_type.
    	* include/bits/shared_ptr_base.h (hash<__shared_ptr<T, L>>): Likewise.

diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index 9f7a40c..e562a42 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -692,7 +692,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       size_t
       operator()(const shared_ptr<_Tp>& __s) const noexcept
-      { return std::hash<_Tp*>()(__s.get()); }
+      {
+	return std::hash<typename shared_ptr<_Tp>::element_type*>()(__s.get());
+      }
     };
 
   // @} group pointer_abstractions
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 1a9e3e9..5e344b8 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -1681,7 +1681,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       size_t
       operator()(const __shared_ptr<_Tp, _Lp>& __s) const noexcept
-      { return std::hash<_Tp*>()(__s.get()); }
+      {
+	return hash<typename __shared_ptr<_Tp, _Lp>::element_type*>()(
+	    __s.get());
+      }
     };
 
 _GLIBCXX_END_NAMESPACE_VERSION


More information about the Libstdc++ mailing list