[libcxx-commits] [libcxx] [libc++] P1789R3: Library Support for Expansion Statements (PR #167184)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sat Nov 8 22:03:03 PST 2025


================
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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++26
+// <utility>
+
+// Expect failures for tuple_element and get with empty integer_sequence
+
+#include <utility>
+
+void f() {
+  using test1 = typename std::tuple_element<0, std::integer_sequence<int>>::
+      type; // expected-error-re@*:* {{static assertion failed{{.*}}Index out of bounds in std::tuple_element<> (std::integer_sequence)}}
+  using test2 = typename std::tuple_element<0, const std::integer_sequence<int>>::
+      type; // expected-error-re@*:* {{static assertion failed{{.*}}Index out of bounds in std::tuple_element<> (const std::integer_sequence)}}
+
+  auto empty = std::integer_sequence<int>();
+  // expected-error-re@*:* {{static assertion failed{{.*}}Index out of bounds in std::get<> (std::integer_sequence)}}
+  // expected-error-re@*:* {{invalid index 0 for pack {{.*}} of size 0}}
+  (void)std::get<0>(empty);
----------------
H-G-Hristov wrote:

Maybe `// clang-format off` these lines to improve readability`

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


More information about the libcxx-commits mailing list