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

Yihan Wang via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 15 02:16:06 PDT 2026


================
@@ -39,36 +39,41 @@ template <class ...Args>
 void F(typename CannotDeduce<std::tuple<Args...>>::type const&) {}
 
 void f() {
-  // Test that we emit our diagnostic from the library.
+  // Constructing a reference element that would bind to a temporary is rejected. Since C++23
+  // ([tuple.cnstr]) the offending constructors are deleted, so the error is reported at the call;
+  // before C++23 the bind is caught by a static_assert in the library (with Clang additionally
+  // diagnosing the dangling reference member).
+#if TEST_STD_VER >= 23
+  // expected-error@*:* 8 {{deleted}}
+#else
   // expected-error at tuple:* 8 {{Attempted construction of reference element binds to a temporary whose lifetime has ended}}
-
-  // Good news everybody! Clang now diagnoses this for us!
   // expected-error at tuple:* 0+ {{reference member '__value_' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
+#endif
 
   {
-    F<int, const std::string&>(std::make_tuple(1, "abc")); // expected-note 1 {{requested here}}
+    F<int, const std::string&>(std::make_tuple(1, "abc"));
----------------
yronglin wrote:

Added it back.

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


More information about the libcxx-commits mailing list