[libcxx-commits] [libcxx] [libc++] LWG2899: Constrain move special functions of `tuple` and `unique_ptr` (PR #167211)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sun Nov 9 08:53:14 PST 2025


================
@@ -208,9 +209,15 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
   template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
   _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
 
-  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
-      : __ptr_(__u.release()),
-        __deleter_(std::forward<deleter_type>(__u.get_deleter())) {}
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
+#if _LIBCPP_STD_VER >= 20
+  unique_ptr(unique_ptr&& __u) noexcept
+    requires is_move_constructible_v<_Dp>
+#else
+  unique_ptr(_If<is_move_constructible<_Dp>::value, unique_ptr&&, __nat> __u) _NOEXCEPT
+#endif
----------------
Zingam wrote:

This looks very ugly. Wouldn't it be better to just copy the full signature twice instead of splitting it?

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


More information about the libcxx-commits mailing list