[libcxx-commits] [libcxx] [libc++][unique_ptr] Implement LWG 4144: Disallow unique_ptr<T&, D> (PR #209018)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jul 12 23:04:30 PDT 2026
================
@@ -111,6 +118,8 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
public:
typedef _Tp element_type;
typedef _Dp deleter_type;
+
+ static_assert(__is_pointable<_Tp>, "unique_ptr<T, D> requires T* to be a valid type");
----------------
emmett2020 wrote:
Thx. I think moving the assertion below the existing `static_assert` would generate additional error message. Since that places it after the pointer alias, `__pointer<_Tp, deleter_type>` attempts to form `_Tp*` first, causing `__pointer` to produce additional errors. Such as:
```bash
allocator_traits.h:46:1: error:
'__pointer' declared as a pointer to a reference of type 'int &'
```
Therefor, I think the pointability assertion should remain before the pointer alias.
https://github.com/llvm/llvm-project/pull/209018
More information about the libcxx-commits
mailing list