summaryrefslogtreecommitdiffstats
blob: 73d54f11f810e19e46b7db6bd38771028e13d3bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// Copyright (C) 2012-2013 Vicente J. Botet Escriba
//
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// 2013/04 Vicente J. Botet Escriba
//   Provide implementation up to 10 parameters when BOOST_NO_CXX11_VARIADIC_TEMPLATES is defined.
// 2012/11 Vicente J. Botet Escriba
//   Adapt to boost libc++ implementation

//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
// The make_tuple_indices C++11 code is based on the one from libcxx.
//===----------------------------------------------------------------------===//

#ifndef BOOST_THREAD_DETAIL_MAKE_TUPLE_INDICES_HPP
#define BOOST_THREAD_DETAIL_MAKE_TUPLE_INDICES_HPP

#include <boost/config.hpp>
#include <boost/static_assert.hpp>

namespace boost
{
  namespace detail
  {

#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
    // make_tuple_indices

    template <std::size_t...> struct tuple_indices
    {};

    template <std::size_t Sp, class IntTuple, std::size_t Ep>
    struct make_indices_imp;

    template <std::size_t Sp, std::size_t ...Indices, std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<Indices...>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<Indices..., Sp>, Ep>::type type;
    };

    template <std::size_t Ep, std::size_t ...Indices>
    struct make_indices_imp<Ep, tuple_indices<Indices...>, Ep>
    {
      typedef tuple_indices<Indices...> type;
    };

    template <std::size_t Ep, std::size_t Sp = 0>
    struct make_tuple_indices
    {
      BOOST_STATIC_ASSERT_MSG(Sp <= Ep, "make_tuple_indices input error");
      typedef typename make_indices_imp<Sp, tuple_indices<>, Ep>::type type;
    };
#else

    // - tuple forward declaration -----------------------------------------------
    template <
      std::size_t T0 = 0, std::size_t T1 = 0, std::size_t T2 = 0,
      std::size_t T3 = 0, std::size_t T4 = 0, std::size_t T5 = 0,
      std::size_t T6 = 0, std::size_t T7 = 0, std::size_t T8 = 0,
      std::size_t T9 = 0>
    class tuple_indices {};

    template <std::size_t Sp, class IntTuple, std::size_t Ep>
    struct make_indices_imp;

    template <std::size_t Sp, std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0, I1>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0, I1 , I2>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, I2, Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0, I1 , I2, I3>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, I2, I3, Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0, I1 , I2, I3, I4>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, I2, I3, I4, Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5, std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0, I1 , I2, I3, I4, I5>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, I2, I3, I4, I5, Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5
    , std::size_t I6
    , std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0, I1 , I2, I3, I4, I5, I6>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, I2, I3, I4, I5, I6, Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5
    , std::size_t I6
    , std::size_t I7
    , std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0, I1 , I2, I3, I4, I5, I6, I7>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7, Sp>, Ep>::type type;
    };
    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5
    , std::size_t I6
    , std::size_t I7
    , std::size_t I8
    , std::size_t Ep>
    struct make_indices_imp<Sp, tuple_indices<I0, I1 , I2, I3, I4, I5, I6, I7, I8>, Ep>
    {
      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7, I8, Sp>, Ep>::type type;
    };
//    template <std::size_t Sp, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5
//    , std::size_t I6
//    , std::size_t I7
//    , std::size_t I8
//    , std::size_t I9
//    , std::size_t Ep>
//    struct make_indices_imp<Sp, tuple_indices<I0, I1 , I2, I3, I4, I5, I6, I7, I8, I9>, Ep>
//    {
//      typedef typename make_indices_imp<Sp+1, tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, Sp>, Ep>::type type;
//    };

    template <std::size_t Ep>
    struct make_indices_imp<Ep, tuple_indices<>, Ep>
    {
      typedef tuple_indices<> type;
    };
    template <std::size_t Ep, std::size_t I0>
    struct make_indices_imp<Ep, tuple_indices<I0>, Ep>
    {
      typedef tuple_indices<I0> type;
    };
    template <std::size_t Ep, std::size_t I0, std::size_t I1>
    struct make_indices_imp<Ep, tuple_indices<I0, I1>, Ep>
    {
      typedef tuple_indices<I0, I1> type;
    };
    template <std::size_t Ep, std::size_t I0, std::size_t I1, std::size_t I2>
    struct make_indices_imp<Ep, tuple_indices<I0, I1, I2>, Ep>
    {
      typedef tuple_indices<I0, I1, I2> type;
    };
    template <std::size_t Ep, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3>
    struct make_indices_imp<Ep, tuple_indices<I0, I1, I2, I3>, Ep>
    {
      typedef tuple_indices<I0, I1, I2, I3> type;
    };
    template <std::size_t Ep, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4>
    struct make_indices_imp<Ep, tuple_indices<I0, I1, I2, I3, I4>, Ep>
    {
      typedef tuple_indices<I0, I1, I2, I3, I4> type;
    };
    template <std::size_t Ep, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5>
    struct make_indices_imp<Ep, tuple_indices<I0, I1, I2, I3, I4, I5>, Ep>
    {
      typedef tuple_indices<I0, I1, I2, I3, I4, I5> type;
    };
    template <std::size_t Ep, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5
    , std::size_t I6
    >
    struct make_indices_imp<Ep, tuple_indices<I0, I1, I2, I3, I4, I5, I6>, Ep>
    {
      typedef tuple_indices<I0, I1, I2, I3, I4, I5, I6> type;
    };
    template <std::size_t Ep, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5
    , std::size_t I6
    , std::size_t I7
    >
    struct make_indices_imp<Ep, tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7>, Ep>
    {
      typedef tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7> type;
    };
    template <std::size_t Ep, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5
    , std::size_t I6
    , std::size_t I7
    , std::size_t I8
    >
    struct make_indices_imp<Ep, tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7, I8>, Ep>
    {
      typedef tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7, I8> type;
    };

    template <std::size_t Ep, std::size_t I0, std::size_t I1, std::size_t I2, std::size_t I3, std::size_t I4, std::size_t I5
    , std::size_t I6
    , std::size_t I7
    , std::size_t I8
    , std::size_t I9
    >
    struct make_indices_imp<Ep, tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7, I8, I9>, Ep>
    {
      typedef tuple_indices<I0, I1, I2, I3, I4, I5, I6, I7, I8, I9> type;
    };

    template <std::size_t Ep, std::size_t Sp = 0>
    struct make_tuple_indices
    {
      BOOST_STATIC_ASSERT_MSG(Sp <= Ep, "make_tuple_indices input error");
      typedef typename make_indices_imp<Sp, tuple_indices<>, Ep>::type type;
    };

#endif
  }
}

#endif // header