aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Grosheintz <luc.grosheintz@gmail.com>2025-09-02 09:59:44 +0200
committerTomasz KamiƄski <tkaminsk@redhat.com>2025-09-02 13:27:45 +0200
commitdea668daa2ea8f9d3d8058dac56e60ebe79255c1 (patch)
tree476b861b5e0b85e844f950160587d52c29aa20c5
parentcfc9a42e8b533cad39ea9e1c4d5a06d4ba82be48 (diff)
downloadgcc-dea668daa2ea8f9d3d8058dac56e60ebe79255c1.zip
gcc-dea668daa2ea8f9d3d8058dac56e60ebe79255c1.tar.gz
gcc-dea668daa2ea8f9d3d8058dac56e60ebe79255c1.tar.bz2
libstdc++: Move _Index_tuple, _Build_index_tuple to <type_traits>.
As preparation for implementing std::constant_wrapper that's part of the C++26 version of the <type_traits> header, the two classes _Index_tuple and _Build_index_tuple are moved to <type_traits>. These two helpers are needed by std::constant_wrapper to initialize the elements of one C array with another. Since, <bits/utility.h> already includes <type_traits> 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 <type_traits> and therefore doesn't change which headers provide user-facing features. libstdc++-v3/ChangeLog: * include/bits/utility.h (_Index_tuple): Move to <type_traits>. (_Build_index_tuple): Ditto. * include/std/type_traits (_Index_tuple): Ditto. (_Build_index_tuple): Ditto. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
-rw-r--r--libstdc++-v3/include/bits/utility.h20
-rw-r--r--libstdc++-v3/include/std/type_traits22
2 files changed, 22 insertions, 20 deletions
diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h
index 84d25e0..4e57465 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<size_t... _Indexes> struct _Index_tuple { };
-
- // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>.
- template<size_t _Num>
- struct _Build_index_tuple
- {
-#if __has_builtin(__make_integer_seq)
- template<typename, size_t... _Indices>
- 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 ff23544..4636457 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -4280,6 +4280,28 @@ template<typename _Ret, typename _Fn, typename... _Args>
#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<size_t... _Indexes> struct _Index_tuple { };
+
+ // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>.
+ template<size_t _Num>
+ struct _Build_index_tuple
+ {
+#if __has_builtin(__make_integer_seq)
+ template<typename, size_t... _Indices>
+ 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