mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
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>
This commit is contained in:
committed by
Tomasz Kamiński
parent
cfc9a42e8b
commit
dea668daa2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user