Stxxl  1.3.2
tuple.h
1 /***************************************************************************
2  * include/stxxl/bits/common/tuple.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2003 Roman Dementiev <[email protected]>
7  *
8  * Distributed under the Boost Software License, Version 1.0.
9  * (See accompanying file LICENSE_1_0.txt or copy at
10  * http://www.boost.org/LICENSE_1_0.txt)
11  **************************************************************************/
12 
13 #ifndef STXXL_TUPLE_HEADER
14 #define STXXL_TUPLE_HEADER
15 
16 #include <stxxl/bits/namespace.h>
17 #include <stxxl/bits/common/tmeta.h>
18 
19 
20 __STXXL_BEGIN_NAMESPACE
21 
22 struct Plug { };
23 
24 
25 template <class T1,
26  class T2,
27  class T3,
28  class T4,
29  class T5,
30  class T6
31  >
32 struct tuple_base
33 {
34  typedef T1 first_type;
35  typedef T2 second_type;
36  typedef T3 third_type;
37  typedef T4 fourth_type;
38  typedef T5 fifth_type;
39  typedef T6 sixth_type;
40 
41  template <int I>
42  struct item_type
43  {
44 /*
45  typedef typename SWITCH<I, CASE<1,first_type,
46  CASE<2,second_type,
47  CASE<3,third_type,
48  CASE<4,fourth_type,
49  CASE<5,fifth_type,
50  CASE<6,sixth_type,
51  CASE<DEFAULT,void
52  > > > > > > > >::result result;
53 */
54  };
55 };
56 
57 
61 template <class T1,
62  class T2 = Plug,
63  class T3 = Plug,
64  class T4 = Plug,
65  class T5 = Plug,
66  class T6 = Plug
67  >
68 struct tuple
69 {
70  typedef T1 first_type;
71  typedef T2 second_type;
72  typedef T3 third_type;
73  typedef T4 fourth_type;
74  typedef T5 fifth_type;
75  typedef T6 sixth_type;
76 
77  template <int I>
78  struct item_type
79  {
80  typedef typename SWITCH<I, CASE<1, first_type,
81  CASE<2, second_type,
82  CASE<3, third_type,
83  CASE<4, fourth_type,
84  CASE<5, fifth_type,
85  CASE<6, sixth_type,
86  CASE<DEFAULT, void
87  > > > > > > > >::result result;
88  };
89 
91  first_type first;
93  second_type second;
95  third_type third;
97  fourth_type fourth;
99  fifth_type fifth;
101  sixth_type sixth;
102 
103  tuple() { }
104  tuple(first_type fir,
105  second_type sec,
106  third_type thi,
107  fourth_type fou,
108  fifth_type fif,
109  sixth_type six
110  ) :
111  first(fir),
112  second(sec),
113  third(thi),
114  fourth(fou),
115  fifth(fif),
116  sixth(six)
117  { }
118 };
119 
121 template <class T1>
122 struct tuple<T1, Plug, Plug, Plug, Plug>
123 {
124  typedef T1 first_type;
125 
126  first_type first;
127 
128  template <int I>
129  struct item_type
130  {
131  typedef typename IF<I == 1, first_type, void>::result result;
132  };
133 
134  tuple() { }
135  tuple(first_type fi) :
136  first(fi)
137  { }
138 };
139 
141 template <class T1, class T2>
142 struct tuple<T1, T2, Plug, Plug, Plug, Plug>
143 {
144  typedef T1 first_type;
145  typedef T2 second_type;
146 
147  template <int I>
148  struct item_type
149  {
150  typedef typename SWITCH<I, CASE<1, first_type,
151  CASE<2, second_type,
152  CASE<DEFAULT, void>
153  > > >::result result;
154  };
155 
156  first_type first;
157  second_type second;
158 
159  tuple() { }
160  tuple(first_type fi,
161  second_type se
162  ) :
163  first(fi),
164  second(se)
165  { }
166 };
167 
168 
170 template <class T1,
171  class T2,
172  class T3
173  >
174 struct tuple<T1, T2, T3, Plug, Plug, Plug>
175 {
176  typedef T1 first_type;
177  typedef T2 second_type;
178  typedef T3 third_type;
179 
180  template <int I>
181  struct item_type
182  {
183  typedef typename SWITCH<I, CASE<1, first_type,
184  CASE<2, second_type,
185  CASE<3, second_type,
186  CASE<DEFAULT, void>
187  > > > >::result result;
188  };
189 
190 
191  first_type first;
192  second_type second;
193  third_type third;
194 
195  tuple() { }
196  tuple(first_type fir,
197  second_type sec,
198  third_type thi
199  ) :
200  first(fir),
201  second(sec),
202  third(thi)
203  { }
204 };
205 
207 template <class T1,
208  class T2,
209  class T3,
210  class T4
211  >
212 struct tuple<T1, T2, T3, T4, Plug, Plug>
213 {
214  typedef T1 first_type;
215  typedef T2 second_type;
216  typedef T3 third_type;
217  typedef T4 fourth_type;
218 
219  template <int I>
220  struct item_type
221  {
222  typedef typename SWITCH<I, CASE<1, first_type,
223  CASE<2, second_type,
224  CASE<3, third_type,
225  CASE<4, fourth_type,
226  CASE<DEFAULT, void
227  > > > > > >::result result;
228  };
229 
230 
231  first_type first;
232  second_type second;
233  third_type third;
234  fourth_type fourth;
235 
236  tuple() { }
237  tuple(first_type fir,
238  second_type sec,
239  third_type thi,
240  fourth_type fou
241  ) :
242  first(fir),
243  second(sec),
244  third(thi),
245  fourth(fou)
246  { }
247 };
248 
250 template <class T1,
251  class T2,
252  class T3,
253  class T4,
254  class T5
255  >
256 struct tuple<T1, T2, T3, T4, T5, Plug>
257 {
258  typedef T1 first_type;
259  typedef T2 second_type;
260  typedef T3 third_type;
261  typedef T4 fourth_type;
262  typedef T5 fifth_type;
263 
264 
265  template <int I>
266  struct item_type
267  {
268  typedef typename SWITCH<I, CASE<1, first_type,
269  CASE<2, second_type,
270  CASE<3, third_type,
271  CASE<4, fourth_type,
272  CASE<5, fifth_type,
273  CASE<DEFAULT, void
274  > > > > > > >::result result;
275  };
276 
277  first_type first;
278  second_type second;
279  third_type third;
280  fourth_type fourth;
281  fifth_type fifth;
282 
283  tuple() { }
284  tuple(first_type fir,
285  second_type sec,
286  third_type thi,
287  fourth_type fou,
288  fifth_type fif
289  ) :
290  first(fir),
291  second(sec),
292  third(thi),
293  fourth(fou),
294  fifth(fif)
295  { }
296 };
297 
298 /*
299  template <class tuple_type,int I>
300  typename tuple_type::item_type<I>::result get(const tuple_type & t)
301  {
302  return NULL;
303  }
304 */
305 
306 __STXXL_END_NAMESPACE
307 
308 #endif // !STXXL_TUPLE_HEADER
sixth_type sixth
Sixth tuple component.
Definition: tuple.h:101
third_type third
Third tuple component.
Definition: tuple.h:95
first_type first
First tuple component.
Definition: tuple.h:91
k-Tuple data type
Definition: tuple.h:68
fourth_type fourth
Fourth tuple component.
Definition: tuple.h:97
second_type second
Second tuple component.
Definition: tuple.h:93
fifth_type fifth
Fifth tuple component.
Definition: tuple.h:99