From dea668daa2ea8f9d3d8058dac56e60ebe79255c1 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Tue, 2 Sep 2025 09:59:44 +0200 Subject: [PATCH] libstdc++: Move _Index_tuple, _Build_index_tuple to . As preparation for implementing std::constant_wrapper that's part of the C++26 version of the header, the two classes _Index_tuple and _Build_index_tuple are moved to . These two helpers are needed by std::constant_wrapper to initialize the elements of one C array with another. Since, already includes this solution avoids creating a very small header file for just these two internal classes. This approach doesn't move std::index_sequence and related code to and therefore doesn't change which headers provide user-facing features. libstdc++-v3/ChangeLog: * include/bits/utility.h (_Index_tuple): Move to . (_Build_index_tuple): Ditto. * include/std/type_traits (_Index_tuple): Ditto. (_Build_index_tuple): Ditto. Reviewed-by: Jonathan Wakely Signed-off-by: Luc Grosheintz --- libstdc++-v3/include/bits/utility.h | 20 -------------------- libstdc++-v3/include/std/type_traits | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h index 84d25e0c658..4e574658eba 100644 --- a/libstdc++-v3/include/bits/utility.h +++ b/libstdc++-v3/include/bits/utility.h @@ -137,26 +137,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using tuple_element_t = typename tuple_element<__i, _Tp>::type; #endif - // Stores a tuple of indices. Used by tuple and pair, and by bind() to - // extract the elements in a tuple. - template struct _Index_tuple { }; - - // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. - template - struct _Build_index_tuple - { -#if __has_builtin(__make_integer_seq) - template - using _IdxTuple = _Index_tuple<_Indices...>; - - // Clang defines __make_integer_seq for this purpose. - using __type = __make_integer_seq<_IdxTuple, size_t, _Num>; -#else - // For GCC and other compilers, use __integer_pack instead. - using __type = _Index_tuple<__integer_pack(_Num)...>; -#endif - }; - #ifdef __glibcxx_integer_sequence // C++ >= 14 /// Class template integer_sequence diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index ff23544fbf0..4636457eb5a 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -4280,6 +4280,28 @@ template #endif // C++2a +#if __cplusplus >= 201103L + // Stores a tuple of indices. Used by tuple and pair, and by bind() to + // extract the elements in a tuple. + template struct _Index_tuple { }; + + // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. + template + struct _Build_index_tuple + { +#if __has_builtin(__make_integer_seq) + template + using _IdxTuple = _Index_tuple<_Indices...>; + + // Clang defines __make_integer_seq for this purpose. + using __type = __make_integer_seq<_IdxTuple, size_t, _Num>; +#else + // For GCC and other compilers, use __integer_pack instead. + using __type = _Index_tuple<__integer_pack(_Num)...>; +#endif + }; +#endif // C++11 + /// @} group metaprogramming _GLIBCXX_END_NAMESPACE_VERSION -- 2.47.3