[libcxx-commits] [libcxx] [libc++] P1789R3: Library Support for Expansion Statements (PR #167184)
Matthias Wippich via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Nov 9 22:58:14 PST 2025
================
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template<class T, T... Values>
+// struct tuple_size<integer_sequence<T, Values...>>;
+// template<size_t I, class T, T... Values>
+// struct tuple_element<I, integer_sequence<T, Values...>>;
+// template<size_t I, class T, T... Values>
+// struct tuple_element<I, const integer_sequence<T, Values...>>;
+// template<size_t I, class T, T... Values>
+// constexpr T get(integer_sequence<T, Values...>) noexcept;
+
+#include <tuple>
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+constexpr void test() {
+ using empty = std::integer_sequence<int>;
+ static_assert(std::tuple_size_v<empty> == 0);
+ static_assert(std::tuple_size_v<const empty> == 0);
+
+ using size4 = std::integer_sequence<int, 9, 8, 7, 2>;
+ static_assert(std::tuple_size_v<size4> == 4);
+ static_assert(std::tuple_size_v<const size4> == 4);
+
+ static_assert(std::is_same_v<std::tuple_element_t<0, size4>, int>);
+ static_assert(std::is_same_v<std::tuple_element_t<1, size4>, int>);
+ static_assert(std::is_same_v<std::tuple_element_t<2, size4>, int>);
+ static_assert(std::is_same_v<std::tuple_element_t<3, size4>, int>);
+
+ static_assert(std::is_same_v<std::tuple_element_t<0, const size4>, int>);
+ static_assert(std::is_same_v<std::tuple_element_t<1, const size4>, int>);
+ static_assert(std::is_same_v<std::tuple_element_t<2, const size4>, int>);
+ static_assert(std::is_same_v<std::tuple_element_t<3, const size4>, int>);
+
+ constexpr static size4 seq4{};
----------------
Tsche wrote:
This mirrors the intended use case of that feature as closely as possible without relying on unimplemented features from P2686.
https://github.com/llvm/llvm-project/pull/167184
More information about the libcxx-commits
mailing list