1 |
301 |
jeremybenn |
// { dg-do compile }
|
2 |
|
|
// { dg-options "-O3 -floop-interchange -Wno-conversion-null" }
|
3 |
|
|
|
4 |
|
|
void __throw_bad_alloc ();
|
5 |
|
|
|
6 |
|
|
template void
|
7 |
|
|
swap (_Tp & __a, _Tp __b)
|
8 |
|
|
{
|
9 |
|
|
__a = __b;
|
10 |
|
|
}
|
11 |
|
|
|
12 |
|
|
template struct iterator
|
13 |
|
|
{
|
14 |
|
|
typedef _Category iterator_category;
|
15 |
|
|
};
|
16 |
|
|
|
17 |
|
|
template struct allocator
|
18 |
|
|
{
|
19 |
|
|
typedef __SIZE_TYPE__ size_type;
|
20 |
|
|
typedef _Tp pointer;
|
21 |
|
|
pointer allocate (size_type)
|
22 |
|
|
{
|
23 |
|
|
__throw_bad_alloc ();
|
24 |
|
|
return __null;
|
25 |
|
|
}
|
26 |
|
|
};
|
27 |
|
|
|
28 |
|
|
template >class unbounded_array;
|
29 |
|
|
template >class vector;
|
30 |
|
|
template class scalar_vector;
|
31 |
|
|
template struct random_access_iterator_base : public iterator
|
32 |
|
|
{
|
33 |
|
|
};
|
34 |
|
|
|
35 |
|
|
template struct promote_traits
|
36 |
|
|
{
|
37 |
|
|
typedef __typeof__ ((X ())) promote_type;
|
38 |
|
|
};
|
39 |
|
|
|
40 |
|
|
template struct scalar_traits
|
41 |
|
|
{
|
42 |
|
|
typedef T const_reference;
|
43 |
|
|
typedef T reference;
|
44 |
|
|
};
|
45 |
|
|
|
46 |
|
|
template struct type_traits : scalar_traits
|
47 |
|
|
{
|
48 |
|
|
};
|
49 |
|
|
|
50 |
|
|
struct dense_proxy_tag
|
51 |
|
|
{
|
52 |
|
|
};
|
53 |
|
|
|
54 |
|
|
template struct iterator_base_traits;
|
55 |
|
|
|
56 |
|
|
template <> struct iterator_base_traits
|
57 |
|
|
{
|
58 |
|
|
template struct iterator_base
|
59 |
|
|
{
|
60 |
|
|
typedef random_access_iterator_base type;
|
61 |
|
|
};
|
62 |
|
|
};
|
63 |
|
|
|
64 |
|
|
template struct iterator_restrict_traits
|
65 |
|
|
{
|
66 |
|
|
typedef I1 iterator_category;
|
67 |
|
|
};
|
68 |
|
|
|
69 |
|
|
template class storage_array
|
70 |
|
|
{
|
71 |
|
|
};
|
72 |
|
|
|
73 |
|
|
template struct unbounded_array : public storage_array >
|
74 |
|
|
{
|
75 |
|
|
typedef typename ALLOC::size_type size_type;
|
76 |
|
|
typedef T & reference;
|
77 |
|
|
typedef T *pointer;
|
78 |
|
|
unbounded_array (size_type size, ALLOC = ALLOC ()) : alloc_ (), size_ (size)
|
79 |
|
|
{
|
80 |
|
|
alloc_.allocate (size_);
|
81 |
|
|
}
|
82 |
|
|
~unbounded_array ()
|
83 |
|
|
{
|
84 |
|
|
if (size_)
|
85 |
|
|
for (;;);
|
86 |
|
|
}
|
87 |
|
|
size_type
|
88 |
|
|
size () const
|
89 |
|
|
{
|
90 |
|
|
return size_;
|
91 |
|
|
}
|
92 |
|
|
reference
|
93 |
|
|
operator[] (size_type i)
|
94 |
|
|
{
|
95 |
|
|
return data_[i];
|
96 |
|
|
}
|
97 |
|
|
void
|
98 |
|
|
swap (unbounded_array & a)
|
99 |
|
|
{
|
100 |
|
|
::swap (size_, a.size_);
|
101 |
|
|
}
|
102 |
|
|
ALLOC alloc_;
|
103 |
|
|
size_type size_;
|
104 |
|
|
pointer data_;
|
105 |
|
|
};
|
106 |
|
|
|
107 |
|
|
template struct scalar_binary_functor
|
108 |
|
|
{
|
109 |
|
|
typedef typename promote_traits ::promote_type result_type;
|
110 |
|
|
};
|
111 |
|
|
|
112 |
|
|
template struct scalar_plus : public scalar_binary_functor
|
113 |
|
|
{
|
114 |
|
|
};
|
115 |
|
|
|
116 |
|
|
template struct scalar_multiplies : public scalar_binary_functor
|
117 |
|
|
{
|
118 |
|
|
};
|
119 |
|
|
|
120 |
|
|
template struct scalar_binary_assign_functor
|
121 |
|
|
{
|
122 |
|
|
typedef typename type_traits ::reference argument1_type;
|
123 |
|
|
typedef typename type_traits ::const_reference argument2_type;
|
124 |
|
|
};
|
125 |
|
|
|
126 |
|
|
template struct scalar_assign : public scalar_binary_assign_functor
|
127 |
|
|
{
|
128 |
|
|
typedef typename scalar_binary_assign_functor ::argument1_type argument1_type;
|
129 |
|
|
typedef typename scalar_binary_assign_functor ::argument2_type argument2_type;
|
130 |
|
|
static const bool computed = false;
|
131 |
|
|
static void
|
132 |
|
|
apply (argument1_type t1, argument2_type t2)
|
133 |
|
|
{
|
134 |
|
|
t1 = t2;
|
135 |
|
|
}
|
136 |
|
|
};
|
137 |
|
|
|
138 |
|
|
template struct vector_expression
|
139 |
|
|
{
|
140 |
|
|
typedef E expression_type;
|
141 |
|
|
const expression_type &
|
142 |
|
|
operator () () const
|
143 |
|
|
{
|
144 |
|
|
return *static_cast (this);
|
145 |
|
|
}
|
146 |
|
|
};
|
147 |
|
|
|
148 |
|
|
template class vector_container : public vector_expression
|
149 |
|
|
{
|
150 |
|
|
};
|
151 |
|
|
|
152 |
|
|
template struct vector_reference : public vector_expression >
|
153 |
|
|
{
|
154 |
|
|
typedef typename E::size_type size_type;
|
155 |
|
|
typename E::const_reference const_reference;
|
156 |
|
|
typedef E referred_type;
|
157 |
|
|
vector_reference (referred_type & e) : e_ (e)
|
158 |
|
|
{
|
159 |
|
|
}
|
160 |
|
|
size_type
|
161 |
|
|
size () const
|
162 |
|
|
{
|
163 |
|
|
return expression ().size ();
|
164 |
|
|
}
|
165 |
|
|
referred_type &
|
166 |
|
|
expression () const
|
167 |
|
|
{
|
168 |
|
|
return e_;
|
169 |
|
|
}
|
170 |
|
|
referred_type &e_;
|
171 |
|
|
};
|
172 |
|
|
|
173 |
|
|
template struct vector_binary : public vector_expression >
|
174 |
|
|
{
|
175 |
|
|
typedef E1 expression1_type;
|
176 |
|
|
typedef E2 expression2_type;
|
177 |
|
|
typedef typename E1::const_closure_type expression1_closure_type;
|
178 |
|
|
typedef typename E2::const_closure_type expression2_closure_type;
|
179 |
|
|
typedef typename promote_traits ::promote_type size_type;
|
180 |
|
|
typedef typename F::result_type value_type;
|
181 |
|
|
|
182 |
|
|
vector_binary (const expression1_type & e1, expression2_type e2) : e1_ (e1), e2_ (e2)
|
183 |
|
|
{
|
184 |
|
|
}
|
185 |
|
|
|
186 |
|
|
size_type
|
187 |
|
|
size () const
|
188 |
|
|
{
|
189 |
|
|
return e1_.size ();
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
class const_iterator : public iterator_base_traits ::iterator_category>::template iterator_base ::type
|
193 |
|
|
{
|
194 |
|
|
};
|
195 |
|
|
expression1_closure_type e1_;
|
196 |
|
|
expression2_closure_type e2_;
|
197 |
|
|
};
|
198 |
|
|
|
199 |
|
|
template struct vector_binary_traits
|
200 |
|
|
{
|
201 |
|
|
typedef vector_binary expression_type;
|
202 |
|
|
typedef expression_type result_type;
|
203 |
|
|
};
|
204 |
|
|
|
205 |
|
|
template typename vector_binary_traits >::result_type
|
206 |
|
|
operator + (vector_expression &e1, const vector_expression &e2)
|
207 |
|
|
{
|
208 |
|
|
typedef typename vector_binary_traits >::expression_type expression_type;
|
209 |
|
|
return expression_type (e1 (), e2 ());
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
template struct vector_binary_scalar2 : public vector_expression >
|
213 |
|
|
{
|
214 |
|
|
typedef vector_binary_scalar2 self_type;
|
215 |
|
|
typedef typename E1::size_type size_type;
|
216 |
|
|
typedef typename F::result_type value_type;
|
217 |
|
|
typedef self_type const_closure_type;
|
218 |
|
|
};
|
219 |
|
|
|
220 |
|
|
template struct vector_binary_scalar2_traits
|
221 |
|
|
{
|
222 |
|
|
typedef vector_binary_scalar2 result_type;
|
223 |
|
|
};
|
224 |
|
|
|
225 |
|
|
template
|
226 |
|
|
typename vector_binary_scalar2_traits >::result_type
|
227 |
|
|
operator * (vector_expression , T2)
|
228 |
|
|
{
|
229 |
|
|
}
|
230 |
|
|
|
231 |
|
|
template struct vector_assign_traits
|
232 |
|
|
{
|
233 |
|
|
typedef SC storage_category;
|
234 |
|
|
};
|
235 |
|
|
|
236 |
|
|
template class F, class V, class E> void
237 |
|
|
indexing_vector_assign (V & v, vector_expression )
|
238 |
|
|
{
|
239 |
|
|
typedef F functor_type;
|
240 |
|
|
typedef typename V::size_type size_type;
|
241 |
|
|
size_type size (v.size ());
|
242 |
|
|
for (size_type i; i
|
243 |
|
|
functor_type::apply (v (i), (i));
|
244 |
|
|
}
|
245 |
|
|
|
246 |
|
|
template class F, class V, class E> void
247 |
|
|
vector_assign (V & v, const vector_expression &e, dense_proxy_tag)
|
248 |
|
|
{
|
249 |
|
|
indexing_vector_assign (v, e);
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
template class F, class V, class E> void
253 |
|
|
vector_assign (V & v, const vector_expression &e)
|
254 |
|
|
{
|
255 |
|
|
typedef typename vector_assign_traits ::storage_category storage_category;
|
256 |
|
|
vector_assign (v, e, storage_category ());
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
template struct vector : public vector_container >
|
260 |
|
|
{
|
261 |
|
|
typedef vector self_type;
|
262 |
|
|
typedef typename A::size_type size_type;
|
263 |
|
|
typedef T value_type;
|
264 |
|
|
typedef typename type_traits ::const_reference const_reference;
|
265 |
|
|
typedef T &reference;
|
266 |
|
|
typedef A array_type;
|
267 |
|
|
typedef vector_reference const_closure_type;
|
268 |
|
|
typedef dense_proxy_tag storage_category;
|
269 |
|
|
vector (size_type size):vector_container (), data_ (size)
|
270 |
|
|
{
|
271 |
|
|
}
|
272 |
|
|
vector (size_type size, value_type):vector_container (), data_ (size)
|
273 |
|
|
{
|
274 |
|
|
}
|
275 |
|
|
template vector (const vector_expression &ae) : vector_container (), data_ (ae ().size ())
|
276 |
|
|
{
|
277 |
|
|
vector_assign (*this, ae);
|
278 |
|
|
}
|
279 |
|
|
size_type
|
280 |
|
|
size () const
|
281 |
|
|
{
|
282 |
|
|
return data_.size ();
|
283 |
|
|
}
|
284 |
|
|
array_type &
|
285 |
|
|
data ()
|
286 |
|
|
{
|
287 |
|
|
return data_;
|
288 |
|
|
}
|
289 |
|
|
reference
|
290 |
|
|
operator () (size_type i)
|
291 |
|
|
{
|
292 |
|
|
return data ()[i];
|
293 |
|
|
}
|
294 |
|
|
template vector operator += (const vector_expression &ae)
|
295 |
|
|
{
|
296 |
|
|
self_type temporary (*this + ae);
|
297 |
|
|
data_.swap (temporary.data ());
|
298 |
|
|
return *this;
|
299 |
|
|
}
|
300 |
|
|
class const_iterator : public random_access_iterator_base
|
301 |
|
|
{
|
302 |
|
|
};
|
303 |
|
|
array_type data_;
|
304 |
|
|
};
|
305 |
|
|
|
306 |
|
|
template struct scalar_vector : public vector_container >
|
307 |
|
|
{
|
308 |
|
|
typedef scalar_vector self_type;
|
309 |
|
|
typedef __SIZE_TYPE__ size_type;
|
310 |
|
|
typedef T value_type;
|
311 |
|
|
typedef T const_reference;
|
312 |
|
|
typedef vector_reference const_closure_type;
|
313 |
|
|
};
|
314 |
|
|
|
315 |
|
|
void
|
316 |
|
|
bar (vector )
|
317 |
|
|
{
|
318 |
|
|
}
|
319 |
|
|
|
320 |
|
|
void
|
321 |
|
|
foo (int n_samp)
|
322 |
|
|
{
|
323 |
|
|
vector xi (n_samp, 0);
|
324 |
|
|
for (int n = 0; n
|
325 |
|
|
{
|
326 |
|
|
vector cos_w_n (n_samp);
|
327 |
|
|
xi += cos_w_n * 6.0;
|
328 |
|
|
}
|
329 |
|
|
vector cos_wd (n_samp);
|
330 |
|
|
xi += cos_wd;
|
331 |
|
|
bar (xi + scalar_vector <> ());
|
332 |
|
|
}
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.
|
|
|