[libcxx-commits] [libcxx] [libc++] Implement P1901R2: owner_hash and owner_equal for shared_ptr/weak_ptr (PR #210551)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 22 01:21:16 PDT 2026


================
@@ -817,6 +823,32 @@ struct owner_less<void>
     typedef void is_transparent;
 };
 
+// class owner_hash:                                                          // C++26
+struct owner_hash
+{
+    template <class _Tp>
+    size_t operator()(shared_ptr<_Tp> const& __p) const noexcept;
+    template <class _Tp>
+    size_t operator()(weak_ptr<_Tp> const& __p) const noexcept;
+
+    typedef void is_transparent;
----------------
frederick-vs-ja wrote:

```suggestion
    using is_transparent = unspecified;
```

The standard doesn't specify the actual type. See [[util.smartptr.owner.hash]](https://eel.is/c++draft/util.smartptr.owner.hash) and [[util.smartptr.owner.equal]](https://eel.is/c++draft/util.smartptr.owner.equal).

https://github.com/llvm/llvm-project/pull/210551


More information about the libcxx-commits mailing list