[hash] Adjust hash for shared_ptr, implement it for std::hash
diff --git a/src/hb-algs.hh b/src/hb-algs.hh
index 9038156..02c5a86 100644
--- a/src/hb-algs.hh
+++ b/src/hb-algs.hh
@@ -240,17 +240,17 @@
   private:
 
   template <typename T> constexpr auto
-  impl (const T& v, hb_priority<2>) const HB_RETURN (uint32_t, hb_deref (v).hash ())
-
-  template <typename T> constexpr auto
-  impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, std::hash<hb_decay<decltype (hb_deref (v))>>{} (hb_deref (v)))
+  impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, hb_deref (v).hash ())
 
   template <typename T> constexpr uint32_t
-  impl (const hb::shared_ptr<T>& v, hb_priority<0>) const
+  impl (const hb::shared_ptr<T>& v, hb_priority<1>) const
   {
-    return (uint32_t) (intptr_t) v.get () * 2654435761u;
+    return (uint32_t) (intptr_t) v.get ()->hash ();
   }
 
+  template <typename T> constexpr auto
+  impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash<hb_decay<decltype (hb_deref (v))>>{} (hb_deref (v)))
+
   public:
 
   template <typename T> constexpr auto
diff --git a/src/hb-cplusplus.hh b/src/hb-cplusplus.hh
index 9bda38c..42c7d56 100644
--- a/src/hb-cplusplus.hh
+++ b/src/hb-cplusplus.hh
@@ -88,8 +88,6 @@
 template<typename T> struct is_shared_ptr : std::false_type {};
 template<typename T> struct is_shared_ptr<shared_ptr<T>> : std::true_type {};
 
-// TODO Implement hash<> and atomic<>
-
 template <typename T,
 	  T * (*_get_empty) (void),
 	  T * (*_reference) (T *),
@@ -135,6 +133,19 @@
 
 } // namespace hb
 
+template<typename T>
+struct std::hash<hb::shared_ptr<T>>
+{
+    std::size_t operator()(const hb::shared_ptr<T>& v) const noexcept
+    {
+        std::size_t h = std::hash<decltype (v.get ())>{}(v.get ());
+        return h;
+    }
+};
+
+// TODO Implement atomic<>
+
+
 #endif /* __cplusplus */
 
 #endif /* HB_CPLUSPLUS_HH */