[libcxx-commits] [libcxx] [libc++] LWG4324: `unique_ptr<void>::operator*` is not SFINAE-friendly (PR #190919)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 15 03:09:08 PDT 2026


================
@@ -117,6 +117,12 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {
   typedef false_type __enable_rval_overload;
 };
 
+template <class, class = void>
+inline const bool __can_dereference = false;
+
+template <class _Tp>
+inline const bool __can_dereference<_Tp, decltype((void)*std::declval<_Tp>())> = true;
----------------
frederick-vs-ja wrote:

I guess that was intentional. `__dereferenceable` was designed for iterators, views, and algorithms, where a `value_type` that's an object type is critical. And `unique_ptr::operator*` seems to intentionally respect the underlying `operator*`.

Also, we've been accepting stuffs like [this](https://godbolt.org/z/777fPf4G9) (as required by the current specification) for years...

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


More information about the libcxx-commits mailing list