[libcxx-commits] [libcxx] [libc++] P2255R2: Add deleted tuple constructor overloads (PR #205379)

Yihan Wang via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 21 00:03:05 PDT 2026


================
@@ -677,16 +714,32 @@ public:
       : __base_(allocator_arg_t(), __a, __from_tuple(), __t) {}
 
 #    if _LIBCPP_STD_VER >= 23
+  template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
+    requires __constructs_dangling_reference_from_tuple_like<const tuple<_Up...>&>
+  tuple(const tuple<_Up...>&) = delete;
----------------
yronglin wrote:

Good catch! I tried locally, the following example can cause compile error when error if we drop the `explicit` specifier on the deleted ctor:

```cpp
#include <tuple>

struct Explicit {
  explicit Explicit(int);
};

using Tuple1 = std::tuple<const long&, Explicit>;
using Tuple2 = std::tuple<int, int>;

struct U {
  U(const Tuple2&) {}
};

void f(Tuple1);
int f(U) { return 0; }

int main() {
  const Tuple2 t{1, 2};
  return f(t); // Should select f(U); the PR currently makes this ambiguous.
}
```

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


More information about the libcxx-commits mailing list