OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [include/] [tr1/] [tuple] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 jlechner
// class template tuple -*- C++ -*-
2
 
3
// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// As a special exception, you may use this file as part of a free software
22
// library without restriction.  Specifically, if other files instantiate
23
// templates or use macros or inline functions from this file, or you compile
24
// this file and link it with other files to produce an executable, this
25
// file does not by itself cause the resulting executable to be covered by
26
// the GNU General Public License.  This exception does not however
27
// invalidate any other reasons why the executable file might be covered by
28
// the GNU General Public License.
29
 
30
/** @file
31
*  This is a TR1 C++ Library header.
32
*/
33
 
34
// Chris Jefferson 
35
 
36
#ifndef _TUPLE
37
#define _TUPLE 1
38
 
39
#include 
40
#include 
41
 
42
namespace std
43
{
44
namespace tr1
45
{
46
 // An implementation specific class which is used in the tuple class
47
 // when the tuple is not maximum possible size.
48
 struct _NullClass { };
49
 
50
 template
51
          typename _Tp2 = _NullClass, typename _Tp3 = _NullClass,
52
          typename _Tp4 = _NullClass, typename _Tp5 = _NullClass,
53
          typename _Tp6 = _NullClass, typename _Tp7 = _NullClass,
54
          typename _Tp8 = _NullClass, typename _Tp9 = _NullClass>
55
   class tuple;
56
 
57
 /// Gives the type of the ith element of a given tuple type.
58
 template
59
   struct tuple_element;
60
 
61
 /// Finds the size of a given tuple type.
62
 template
63
   struct tuple_size;
64
 
65
 // Adds a const reference to a non-reference type.
66
 template
67
   struct __add_c_ref
68
   { typedef const _Tp& type; };
69
 
70
 template
71
   struct __add_c_ref<_Tp&>
72
   { typedef _Tp& type; };
73
 
74
 // Adds a reference to a non-reference type.
75
 template
76
   struct __add_ref
77
   { typedef _Tp& type; };
78
 
79
 template
80
   struct __add_ref<_Tp&>
81
   { typedef _Tp& type; };
82
 
83
 // Class used in the implementation of get
84
 template
85
   struct __get_helper;
86
 
87
 // Returns a const reference to the ith element of a tuple.
88
 // Any const or non-const ref elements are returned with their original type.
89
   template
90
                   typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7,
91
                   typename _Tp8, typename _Tp9>
92
   typename __add_ref
93
                                                        _Tp3, _Tp4, _Tp5,
94
                                                        _Tp6, _Tp7, _Tp8,
95
                                                        _Tp9> >::type>::type
96
   get(tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8,
97
             _Tp9>& __t)
98
   {
99
     return __get_helper<__i, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6,
100
                                    _Tp7, _Tp8, _Tp9> >::get_value(__t);
101
   }
102
 
103
 template
104
                   typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7,
105
                   typename _Tp8, typename _Tp9>
106
   typename __add_c_ref
107
                                                          _Tp3, _Tp4, _Tp5,
108
                                                          _Tp6, _Tp7, _Tp8,
109
                                                          _Tp9> >::type>::type
110
   get(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8,
111
                   _Tp9>& __t)
112
   {
113
     return __get_helper<__i, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6,
114
                                    _Tp7, _Tp8, _Tp9> >::get_value(__t);
115
   }
116
 
117
 // This class helps construct the various comparison operations on tuples
118
 template
119
   struct __tuple_compare;
120
 
121
 template
122
   struct __tuple_compare<0, __i, __j, _Tp, _Up>
123
   {
124
     static bool __eq(const _Tp& __t, const _Up& __u)
125
     {
126
       return get<__i>(__t) == get<__i>(__u) &&
127
          __tuple_compare<0, __i+1, __j, _Tp, _Up>::__eq(__t, __u);
128
     }
129
     static bool __less(const _Tp& __t, const _Up& __u)
130
     {
131
       return (get<__i>(__t) < get<__i>(__u)) || !(get<__i>(__u) < get<__i>(__t)) &&
132
          __tuple_compare<0, __i+1, __j, _Tp, _Up>::__less(__t, __u);
133
     }
134
   };
135
 
136
 template
137
   struct __tuple_compare<0, __i, __i, _Tp, _Up>
138
   {
139
     static bool __eq(const _Tp&, const _Up&)
140
     { return true; }
141
     static bool __less(const _Tp&, const _Up&)
142
     { return false; }
143
   };
144
 
145
 template
146
          typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
147
          typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
148
          typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
149
 bool
150
 operator==(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
151
            const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
152
 {
153
   typedef tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10> _Tp;
154
   typedef tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8,_U9, _U10> _Up;
155
   return __tuple_compare::value - tuple_size<_Tp>::value, 0,
156
                          tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u);
157
 }
158
 
159
 template
160
          typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
161
          typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
162
          typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
163
 bool
164
 operator<(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
165
           const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
166
 {
167
   typedef tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10> _Tp;
168
   typedef tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8,_U9, _U10> _Up;
169
   return __tuple_compare::value - tuple_size<_Tp>::value, 0,
170
                          tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u);
171
 }
172
 
173
 template
174
          typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
175
          typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
176
          typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
177
 bool
178
 operator!=(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
179
            const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
180
 { return !(__t == __u); }
181
 
182
 template
183
          typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
184
          typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
185
          typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
186
 bool
187
 operator>(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
188
           const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
189
 { return __u < __t; }
190
 
191
 template
192
          typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
193
          typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
194
          typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
195
 bool
196
 operator<=(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
197
            const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
198
 { return !(__u < __t); }
199
 
200
 template
201
          typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
202
          typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
203
          typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
204
 bool
205
 operator>=(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
206
            const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
207
 { return !(__t < __u); }
208
 
209
 // Helper which adds a reference to a type when given a reference_wrapper
210
 template
211
   struct __strip_reference_wrapper
212
   {
213
       typedef _Tp __type;
214
   };
215
 
216
 template
217
   struct __strip_reference_wrapper >
218
   {
219
     typedef _Tp& __type;
220
   };
221
 
222
 template
223
   struct __strip_reference_wrapper >
224
   {
225
       typedef _Tp& __type;
226
   };
227
 
228
 template
229
          typename _Tp2 = _NullClass, typename _Tp3 = _NullClass,
230
          typename _Tp4 = _NullClass, typename _Tp5 = _NullClass,
231
          typename _Tp6 = _NullClass, typename _Tp7 = _NullClass,
232
          typename _Tp8 = _NullClass, typename _Tp9 = _NullClass>
233
   struct __stripped_tuple_type
234
   {
235
     typedef tuple::__type,
236
                   typename __strip_reference_wrapper<_Tp1>::__type,
237
                   typename __strip_reference_wrapper<_Tp2>::__type,
238
                   typename __strip_reference_wrapper<_Tp3>::__type,
239
                   typename __strip_reference_wrapper<_Tp4>::__type,
240
                   typename __strip_reference_wrapper<_Tp5>::__type,
241
                   typename __strip_reference_wrapper<_Tp6>::__type,
242
                   typename __strip_reference_wrapper<_Tp7>::__type,
243
                   typename __strip_reference_wrapper<_Tp8>::__type,
244
                   typename __strip_reference_wrapper<_Tp9>::__type>      __type;
245
   };
246
 
247
 // A class (and instance) which can be used in 'tie' when an element
248
 // of a tuple is not required
249
 struct swallow_assign
250
 {
251
   template
252
   swallow_assign&
253
     operator=(const T&)
254
     { return *this; }
255
 };
256
 
257
 // TODO: Put this in some kind of shared file.
258
 namespace
259
 {
260
   swallow_assign ignore;
261
 };
262
 
263
#define _GLIBCXX_CAT(x,y) _GLIBCXX_CAT2(x,y)
264
#define _GLIBCXX_CAT2(x,y) x##y
265
#define _SHORT_REPEAT
266
#define _GLIBCXX_REPEAT_HEADER 
267
#include 
268
#undef _GLIBCXX_REPEAT_HEADER
269
#undef _SHORT_REPEAT
270
}
271
}
272
 
273
#include 
274
 
275
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.