[libcxx-commits] [libcxx] [libc++] P2255R2: Add deleted tuple constructor overloads (PR #205379)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 18 01:07:28 PDT 2026
================
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++23
+
+// <tuple>
+
+// tuple(UTypes&&... u);
+// tuple(tuple<UTypes...>& u);
+// tuple(const tuple<UTypes...>& u);
+// tuple(tuple<UTypes...>&& u);
+// tuple(const tuple<UTypes...>&& u);
+// tuple(pair<U1, U2>& u);
+// tuple(const pair<U1, U2>& u);
+// tuple(pair<U1, U2>&& u);
+// tuple(const pair<U1, U2>&& u);
+//
+// The constructors above are defined as deleted if reference_constructs_from_temporary_v
+// is true for one of the corresponding tuple elements.
+
+#include <memory>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+struct X {
+ X(int);
+};
+
+using Alloc = std::allocator<int>;
+using Tuple = std::tuple<const X&>;
+using PairTuple = std::tuple<const X&, int>;
+using SourceTuple = std::tuple<int>;
+using SourcePair = std::pair<int, int>;
+
+static_assert(std::is_constructible_v<Tuple, X&>);
+static_assert(!std::is_constructible_v<Tuple, int>);
+static_assert(!std::is_constructible_v<Tuple, std::allocator_arg_t, Alloc, int>);
+static_assert(!std::is_constructible_v<Tuple, SourceTuple&>);
+static_assert(!std::is_constructible_v<Tuple, std::allocator_arg_t, Alloc, SourceTuple&>);
+static_assert(!std::is_constructible_v<Tuple, const SourceTuple&>);
+static_assert(!std::is_constructible_v<Tuple, std::allocator_arg_t, Alloc, const SourceTuple&>);
+static_assert(!std::is_constructible_v<Tuple, SourceTuple&&>);
+static_assert(!std::is_constructible_v<Tuple, std::allocator_arg_t, Alloc, SourceTuple&&>);
+static_assert(!std::is_constructible_v<Tuple, const SourceTuple&&>);
+static_assert(!std::is_constructible_v<Tuple, std::allocator_arg_t, Alloc, const SourceTuple&&>);
+static_assert(!std::is_constructible_v<PairTuple, SourcePair&>);
+static_assert(!std::is_constructible_v<PairTuple, std::allocator_arg_t, Alloc, SourcePair&>);
+static_assert(!std::is_constructible_v<PairTuple, const SourcePair&>);
+static_assert(!std::is_constructible_v<PairTuple, std::allocator_arg_t, Alloc, const SourcePair&>);
+static_assert(!std::is_constructible_v<PairTuple, SourcePair&&>);
+static_assert(!std::is_constructible_v<PairTuple, std::allocator_arg_t, Alloc, SourcePair&&>);
+static_assert(!std::is_constructible_v<PairTuple, const SourcePair&&>);
+static_assert(!std::is_constructible_v<PairTuple, std::allocator_arg_t, Alloc, const SourcePair&&>);
+
+int main(int, char**) { return 0; }
----------------
frederick-vs-ja wrote:
There shouldn't be the `main` function in a `.compile.pass.cpp`, unless we need to verify something specific to `main` (but IIUC there's currently no such thing in the standard library).
```suggestion
```
https://github.com/llvm/llvm-project/pull/205379
More information about the libcxx-commits
mailing list