aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2015-11-17 19:54:33 +0000
committerJonathan Wakely <jwakely@redhat.com>2015-11-17 19:54:33 +0000
commit17e5dcf1eb9a471c36a2e8a487306d654fa8b177 (patch)
treee0515b6f47664e16a0c512e442d6d5a4b80fc353 /libstdc++-v3/include
parent431d5e0cfe12b752a3a14ffd9c58ff945bf8a03b (diff)
PR libstdc++/66059 optimise _Build_index_tuple
PR libstdc++/66059 * include/std/utility (_Build_index_tuple): Optimise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@230496 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/std/utility19
1 files changed, 15 insertions, 4 deletions
diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility
index 89b68522ddf..985bcb20215 100644
--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -212,17 +212,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 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
+ template<size_t... _Indexes> struct _Index_tuple { };
+
+ // Concatenates two _Index_tuples.
+ template<typename _Itup1, typename _Itup2> struct _Itup_cat;
+
+ template<size_t... _Ind1, size_t... _Ind2>
+ struct _Itup_cat<_Index_tuple<_Ind1...>, _Index_tuple<_Ind2...>>
{
- typedef _Index_tuple<_Indexes..., sizeof...(_Indexes)> __next;
+ using __type = _Index_tuple<_Ind1..., (_Ind2 + sizeof...(_Ind1))...>;
};
// Builds an _Index_tuple<0, 1, 2, ..., _Num-1>.
template<size_t _Num>
struct _Build_index_tuple
+ : _Itup_cat<typename _Build_index_tuple<_Num / 2>::__type,
+ typename _Build_index_tuple<_Num - _Num / 2>::__type>
+ { };
+
+ template<>
+ struct _Build_index_tuple<1>
{
- typedef typename _Build_index_tuple<_Num - 1>::__type::__next __type;
+ typedef _Index_tuple<0> __type;
};
template<>