]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/bits/valarray_before.h
arm.c (arm_legitimate_index_p): Add VFP load/store index range case.
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / valarray_before.h
CommitLineData
c13bea50
NS
1// The template and inlines for the -*- C++ -*- internal _Meta class.
2
748086b7 3// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
54f38225 4// 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
c13bea50
NS
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
748086b7 9// Free Software Foundation; either version 3, or (at your option)
c13bea50
NS
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
748086b7
JJ
17// Under Section 7 of GPL version 3, you are granted additional
18// permissions described in the GCC Runtime Library Exception, version
19// 3.1, as published by the Free Software Foundation.
20
21// You should have received a copy of the GNU General Public License and
22// a copy of the GCC Runtime Library Exception along with this program;
23// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24// <http://www.gnu.org/licenses/>.
c13bea50 25
20fff8cd 26/** @file valarray_before.h
c13bea50
NS
27 * This is an internal header file, included by other library headers.
28 * You should not attempt to use it directly.
29 */
30
143c27b0
BK
31// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
32
3d7c150e
BK
33#ifndef _VALARRAY_BEFORE_H
34#define _VALARRAY_BEFORE_H 1
c13bea50
NS
35
36#pragma GCC system_header
37
38#include <bits/slice_array.h>
39
3cbc7af0
BK
40_GLIBCXX_BEGIN_NAMESPACE(std)
41
c13bea50
NS
42 //
43 // Implementing a loosened valarray return value is tricky.
44 // First we need to meet 26.3.1/3: we should not add more than
45 // two levels of template nesting. Therefore we resort to template
46 // template to "flatten" loosened return value types.
47 // At some point we use partial specialization to remove one level
48 // template nesting due to _Expr<>
49 //
ed6814f7 50
c13bea50
NS
51 // This class is NOT defined. It doesn't need to.
52 template<typename _Tp1, typename _Tp2> class _Constant;
53
54 // Implementations of unary functions applied to valarray<>s.
55 // I use hard-coded object functions here instead of a generic
56 // approach like pointers to function:
57 // 1) correctness: some functions take references, others values.
58 // we can't deduce the correct type afterwards.
59 // 2) efficiency -- object functions can be easily inlined
60 // 3) be Koenig-lookup-friendly
61
54f38225 62 struct _Abs
c13bea50
NS
63 {
64 template<typename _Tp>
b714a419
PC
65 _Tp operator()(const _Tp& __t) const
66 { return abs(__t); }
c13bea50
NS
67 };
68
54f38225 69 struct _Cos
c13bea50
NS
70 {
71 template<typename _Tp>
b714a419
PC
72 _Tp operator()(const _Tp& __t) const
73 { return cos(__t); }
c13bea50
NS
74 };
75
54f38225 76 struct _Acos
c13bea50
NS
77 {
78 template<typename _Tp>
b714a419
PC
79 _Tp operator()(const _Tp& __t) const
80 { return acos(__t); }
c13bea50
NS
81 };
82
54f38225 83 struct _Cosh
c13bea50
NS
84 {
85 template<typename _Tp>
b714a419
PC
86 _Tp operator()(const _Tp& __t) const
87 { return cosh(__t); }
c13bea50
NS
88 };
89
54f38225 90 struct _Sin
c13bea50
NS
91 {
92 template<typename _Tp>
b714a419
PC
93 _Tp operator()(const _Tp& __t) const
94 { return sin(__t); }
c13bea50
NS
95 };
96
54f38225 97 struct _Asin
c13bea50
NS
98 {
99 template<typename _Tp>
b714a419
PC
100 _Tp operator()(const _Tp& __t) const
101 { return asin(__t); }
c13bea50
NS
102 };
103
54f38225 104 struct _Sinh
c13bea50
NS
105 {
106 template<typename _Tp>
b714a419
PC
107 _Tp operator()(const _Tp& __t) const
108 { return sinh(__t); }
c13bea50
NS
109 };
110
54f38225 111 struct _Tan
c13bea50
NS
112 {
113 template<typename _Tp>
b714a419
PC
114 _Tp operator()(const _Tp& __t) const
115 { return tan(__t); }
c13bea50
NS
116 };
117
54f38225 118 struct _Atan
c13bea50
NS
119 {
120 template<typename _Tp>
b714a419
PC
121 _Tp operator()(const _Tp& __t) const
122 { return atan(__t); }
c13bea50
NS
123 };
124
54f38225 125 struct _Tanh
c13bea50
NS
126 {
127 template<typename _Tp>
b714a419
PC
128 _Tp operator()(const _Tp& __t) const
129 { return tanh(__t); }
c13bea50
NS
130 };
131
54f38225 132 struct _Exp
c13bea50
NS
133 {
134 template<typename _Tp>
b714a419
PC
135 _Tp operator()(const _Tp& __t) const
136 { return exp(__t); }
c13bea50
NS
137 };
138
54f38225 139 struct _Log
c13bea50
NS
140 {
141 template<typename _Tp>
b714a419
PC
142 _Tp operator()(const _Tp& __t) const
143 { return log(__t); }
c13bea50
NS
144 };
145
54f38225 146 struct _Log10
c13bea50
NS
147 {
148 template<typename _Tp>
b714a419
PC
149 _Tp operator()(const _Tp& __t) const
150 { return log10(__t); }
c13bea50
NS
151 };
152
54f38225 153 struct _Sqrt
c13bea50
NS
154 {
155 template<typename _Tp>
b714a419
PC
156 _Tp operator()(const _Tp& __t) const
157 { return sqrt(__t); }
c13bea50
NS
158 };
159
160 // In the past, we used to tailor operator applications semantics
161 // to the specialization of standard function objects (i.e. plus<>, etc.)
162 // That is incorrect. Therefore we provide our own surrogates.
163
164 struct __unary_plus
165 {
166 template<typename _Tp>
b714a419
PC
167 _Tp operator()(const _Tp& __t) const
168 { return +__t; }
c13bea50
NS
169 };
170
171 struct __negate
172 {
173 template<typename _Tp>
b714a419
PC
174 _Tp operator()(const _Tp& __t) const
175 { return -__t; }
c13bea50
NS
176 };
177
178 struct __bitwise_not
179 {
180 template<typename _Tp>
b714a419
PC
181 _Tp operator()(const _Tp& __t) const
182 { return ~__t; }
c13bea50
NS
183 };
184
185 struct __plus
186 {
187 template<typename _Tp>
188 _Tp operator()(const _Tp& __x, const _Tp& __y) const
189 { return __x + __y; }
190 };
191
192 struct __minus
193 {
194 template<typename _Tp>
195 _Tp operator()(const _Tp& __x, const _Tp& __y) const
196 { return __x - __y; }
197 };
198
199 struct __multiplies
200 {
201 template<typename _Tp>
202 _Tp operator()(const _Tp& __x, const _Tp& __y) const
203 { return __x * __y; }
204 };
205
206 struct __divides
207 {
208 template<typename _Tp>
209 _Tp operator()(const _Tp& __x, const _Tp& __y) const
210 { return __x / __y; }
211 };
212
213 struct __modulus
214 {
215 template<typename _Tp>
216 _Tp operator()(const _Tp& __x, const _Tp& __y) const
217 { return __x % __y; }
218 };
219
220 struct __bitwise_xor
221 {
222 template<typename _Tp>
223 _Tp operator()(const _Tp& __x, const _Tp& __y) const
224 { return __x ^ __y; }
225 };
226
227 struct __bitwise_and
228 {
229 template<typename _Tp>
230 _Tp operator()(const _Tp& __x, const _Tp& __y) const
231 { return __x & __y; }
232 };
233
234 struct __bitwise_or
235 {
236 template<typename _Tp>
237 _Tp operator()(const _Tp& __x, const _Tp& __y) const
238 { return __x | __y; }
239 };
240
241 struct __shift_left
242 {
243 template<typename _Tp>
244 _Tp operator()(const _Tp& __x, const _Tp& __y) const
245 { return __x << __y; }
246 };
247
248 struct __shift_right
249 {
250 template<typename _Tp>
251 _Tp operator()(const _Tp& __x, const _Tp& __y) const
252 { return __x >> __y; }
253 };
254
255 struct __logical_and
256 {
257 template<typename _Tp>
258 bool operator()(const _Tp& __x, const _Tp& __y) const
259 { return __x && __y; }
260 };
261
262 struct __logical_or
263 {
264 template<typename _Tp>
265 bool operator()(const _Tp& __x, const _Tp& __y) const
266 { return __x || __y; }
267 };
268
269 struct __logical_not
270 {
271 template<typename _Tp>
54f38225
PC
272 bool operator()(const _Tp& __x) const
273 { return !__x; }
c13bea50
NS
274 };
275
276 struct __equal_to
277 {
278 template<typename _Tp>
279 bool operator()(const _Tp& __x, const _Tp& __y) const
280 { return __x == __y; }
281 };
282
283 struct __not_equal_to
284 {
285 template<typename _Tp>
286 bool operator()(const _Tp& __x, const _Tp& __y) const
847e8c74 287 { return __x != __y; }
c13bea50
NS
288 };
289
290 struct __less
291 {
292 template<typename _Tp>
293 bool operator()(const _Tp& __x, const _Tp& __y) const
294 { return __x < __y; }
295 };
296
297 struct __greater
298 {
299 template<typename _Tp>
300 bool operator()(const _Tp& __x, const _Tp& __y) const
301 { return __x > __y; }
302 };
303
304 struct __less_equal
305 {
306 template<typename _Tp>
307 bool operator()(const _Tp& __x, const _Tp& __y) const
308 { return __x <= __y; }
309 };
310
311 struct __greater_equal
312 {
313 template<typename _Tp>
314 bool operator()(const _Tp& __x, const _Tp& __y) const
315 { return __x >= __y; }
316 };
317
318 // The few binary functions we miss.
54f38225 319 struct _Atan2
c13bea50
NS
320 {
321 template<typename _Tp>
322 _Tp operator()(const _Tp& __x, const _Tp& __y) const
323 { return atan2(__x, __y); }
324 };
325
54f38225 326 struct _Pow
c13bea50
NS
327 {
328 template<typename _Tp>
329 _Tp operator()(const _Tp& __x, const _Tp& __y) const
330 { return pow(__x, __y); }
331 };
332
333
334 // We need these bits in order to recover the return type of
335 // some functions/operators now that we're no longer using
336 // function templates.
337 template<typename, typename _Tp>
338 struct __fun
339 {
340 typedef _Tp result_type;
341 };
342
343 // several specializations for relational operators.
344 template<typename _Tp>
345 struct __fun<__logical_not, _Tp>
346 {
347 typedef bool result_type;
348 };
349
350 template<typename _Tp>
351 struct __fun<__logical_and, _Tp>
352 {
353 typedef bool result_type;
354 };
355
356 template<typename _Tp>
357 struct __fun<__logical_or, _Tp>
358 {
359 typedef bool result_type;
360 };
361
362 template<typename _Tp>
363 struct __fun<__less, _Tp>
364 {
365 typedef bool result_type;
366 };
367
368 template<typename _Tp>
369 struct __fun<__greater, _Tp>
370 {
371 typedef bool result_type;
372 };
373
374 template<typename _Tp>
375 struct __fun<__less_equal, _Tp>
376 {
377 typedef bool result_type;
378 };
379
380 template<typename _Tp>
381 struct __fun<__greater_equal, _Tp>
382 {
383 typedef bool result_type;
384 };
385
386 template<typename _Tp>
387 struct __fun<__equal_to, _Tp>
388 {
389 typedef bool result_type;
390 };
391
392 template<typename _Tp>
393 struct __fun<__not_equal_to, _Tp>
394 {
395 typedef bool result_type;
396 };
397
b714a419
PC
398 //
399 // Apply function taking a value/const reference closure
400 //
c13bea50
NS
401
402 template<typename _Dom, typename _Arg>
ed6814f7 403 class _FunBase
c13bea50
NS
404 {
405 public:
406 typedef typename _Dom::value_type value_type;
ed6814f7 407
c13bea50 408 _FunBase(const _Dom& __e, value_type __f(_Arg))
b714a419 409 : _M_expr(__e), _M_func(__f) {}
c13bea50
NS
410
411 value_type operator[](size_t __i) const
412 { return _M_func (_M_expr[__i]); }
413
414 size_t size() const { return _M_expr.size ();}
415
416 private:
b714a419
PC
417 const _Dom& _M_expr;
418 value_type (*_M_func)(_Arg);
c13bea50
NS
419 };
420
421 template<class _Dom>
ed6814f7 422 struct _ValFunClos<_Expr,_Dom> : _FunBase<_Dom, typename _Dom::value_type>
c13bea50
NS
423 {
424 typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
425 typedef typename _Base::value_type value_type;
426 typedef value_type _Tp;
ed6814f7 427
c13bea50
NS
428 _ValFunClos(const _Dom& __e, _Tp __f(_Tp)) : _Base(__e, __f) {}
429 };
430
431 template<typename _Tp>
432 struct _ValFunClos<_ValArray,_Tp> : _FunBase<valarray<_Tp>, _Tp>
433 {
434 typedef _FunBase<valarray<_Tp>, _Tp> _Base;
435 typedef _Tp value_type;
ed6814f7 436
c13bea50
NS
437 _ValFunClos(const valarray<_Tp>& __v, _Tp __f(_Tp)) : _Base(__v, __f) {}
438 };
439
440 template<class _Dom>
b714a419
PC
441 struct _RefFunClos<_Expr, _Dom>
442 : _FunBase<_Dom, const typename _Dom::value_type&>
c13bea50
NS
443 {
444 typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
445 typedef typename _Base::value_type value_type;
446 typedef value_type _Tp;
ed6814f7 447
c13bea50 448 _RefFunClos(const _Dom& __e, _Tp __f(const _Tp&))
b714a419 449 : _Base(__e, __f) {}
c13bea50
NS
450 };
451
452 template<typename _Tp>
b714a419
PC
453 struct _RefFunClos<_ValArray, _Tp>
454 : _FunBase<valarray<_Tp>, const _Tp&>
c13bea50
NS
455 {
456 typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
457 typedef _Tp value_type;
ed6814f7 458
c13bea50 459 _RefFunClos(const valarray<_Tp>& __v, _Tp __f(const _Tp&))
b714a419 460 : _Base(__v, __f) {}
c13bea50 461 };
ed6814f7 462
c13bea50
NS
463 //
464 // Unary expression closure.
465 //
466
467 template<class _Oper, class _Arg>
468 class _UnBase
469 {
470 public:
471 typedef typename _Arg::value_type _Vt;
472 typedef typename __fun<_Oper, _Vt>::result_type value_type;
473
474 _UnBase(const _Arg& __e) : _M_expr(__e) {}
475
476 value_type operator[](size_t __i) const
847e8c74 477 { return _Oper()(_M_expr[__i]); }
c13bea50
NS
478
479 size_t size() const { return _M_expr.size(); }
b714a419 480
c13bea50
NS
481 private:
482 const _Arg& _M_expr;
483 };
484
485 template<class _Oper, class _Dom>
b714a419
PC
486 struct _UnClos<_Oper, _Expr, _Dom>
487 : _UnBase<_Oper, _Dom>
c13bea50
NS
488 {
489 typedef _Dom _Arg;
490 typedef _UnBase<_Oper, _Dom> _Base;
491 typedef typename _Base::value_type value_type;
ed6814f7 492
c13bea50
NS
493 _UnClos(const _Arg& __e) : _Base(__e) {}
494 };
495
496 template<class _Oper, typename _Tp>
b714a419
PC
497 struct _UnClos<_Oper, _ValArray, _Tp>
498 : _UnBase<_Oper, valarray<_Tp> >
c13bea50
NS
499 {
500 typedef valarray<_Tp> _Arg;
501 typedef _UnBase<_Oper, valarray<_Tp> > _Base;
502 typedef typename _Base::value_type value_type;
ed6814f7 503
c13bea50
NS
504 _UnClos(const _Arg& __e) : _Base(__e) {}
505 };
506
507
508 //
509 // Binary expression closure.
510 //
511
512 template<class _Oper, class _FirstArg, class _SecondArg>
ed6814f7 513 class _BinBase
c13bea50
NS
514 {
515 public:
b714a419
PC
516 typedef typename _FirstArg::value_type _Vt;
517 typedef typename __fun<_Oper, _Vt>::result_type value_type;
c13bea50
NS
518
519 _BinBase(const _FirstArg& __e1, const _SecondArg& __e2)
b714a419 520 : _M_expr1(__e1), _M_expr2(__e2) {}
ed6814f7 521
c13bea50
NS
522 value_type operator[](size_t __i) const
523 { return _Oper()(_M_expr1[__i], _M_expr2[__i]); }
524
525 size_t size() const { return _M_expr1.size(); }
ed6814f7 526
c13bea50
NS
527 private:
528 const _FirstArg& _M_expr1;
529 const _SecondArg& _M_expr2;
530 };
531
532
533 template<class _Oper, class _Clos>
534 class _BinBase2
535 {
536 public:
537 typedef typename _Clos::value_type _Vt;
538 typedef typename __fun<_Oper, _Vt>::result_type value_type;
539
540 _BinBase2(const _Clos& __e, const _Vt& __t)
b714a419 541 : _M_expr1(__e), _M_expr2(__t) {}
c13bea50
NS
542
543 value_type operator[](size_t __i) const
544 { return _Oper()(_M_expr1[__i], _M_expr2); }
545
546 size_t size() const { return _M_expr1.size(); }
547
548 private:
549 const _Clos& _M_expr1;
550 const _Vt& _M_expr2;
551 };
552
553 template<class _Oper, class _Clos>
554 class _BinBase1
555 {
556 public:
557 typedef typename _Clos::value_type _Vt;
558 typedef typename __fun<_Oper, _Vt>::result_type value_type;
559
560 _BinBase1(const _Vt& __t, const _Clos& __e)
b714a419 561 : _M_expr1(__t), _M_expr2(__e) {}
c13bea50
NS
562
563 value_type operator[](size_t __i) const
564 { return _Oper()(_M_expr1, _M_expr2[__i]); }
ed6814f7 565
c13bea50
NS
566 size_t size() const { return _M_expr2.size(); }
567
568 private:
569 const _Vt& _M_expr1;
570 const _Clos& _M_expr2;
571 };
ed6814f7 572
c13bea50
NS
573 template<class _Oper, class _Dom1, class _Dom2>
574 struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
b714a419 575 : _BinBase<_Oper, _Dom1, _Dom2>
c13bea50 576 {
b714a419 577 typedef _BinBase<_Oper, _Dom1, _Dom2> _Base;
c13bea50 578 typedef typename _Base::value_type value_type;
ed6814f7 579
c13bea50
NS
580 _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
581 };
582
583 template<class _Oper, typename _Tp>
b714a419
PC
584 struct _BinClos<_Oper,_ValArray, _ValArray, _Tp, _Tp>
585 : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> >
c13bea50 586 {
b714a419 587 typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base;
0701ea2e 588 typedef typename _Base::value_type value_type;
c13bea50
NS
589
590 _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w)
b714a419 591 : _Base(__v, __w) {}
c13bea50
NS
592 };
593
594 template<class _Oper, class _Dom>
b714a419
PC
595 struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type>
596 : _BinBase<_Oper, _Dom, valarray<typename _Dom::value_type> >
c13bea50
NS
597 {
598 typedef typename _Dom::value_type _Tp;
599 typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
600 typedef typename _Base::value_type value_type;
ed6814f7 601
c13bea50 602 _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2)
b714a419 603 : _Base(__e1, __e2) {}
c13bea50
NS
604 };
605
606 template<class _Oper, class _Dom>
b714a419
PC
607 struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom>
608 : _BinBase<_Oper, valarray<typename _Dom::value_type>,_Dom>
c13bea50
NS
609 {
610 typedef typename _Dom::value_type _Tp;
b714a419 611 typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base;
c13bea50 612 typedef typename _Base::value_type value_type;
ed6814f7 613
c13bea50 614 _BinClos(const valarray<_Tp>& __e1, const _Dom& __e2)
b714a419 615 : _Base(__e1, __e2) {}
c13bea50
NS
616 };
617
618 template<class _Oper, class _Dom>
b714a419
PC
619 struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type>
620 : _BinBase2<_Oper, _Dom>
c13bea50
NS
621 {
622 typedef typename _Dom::value_type _Tp;
623 typedef _BinBase2<_Oper,_Dom> _Base;
624 typedef typename _Base::value_type value_type;
ed6814f7 625
c13bea50
NS
626 _BinClos(const _Dom& __e1, const _Tp& __e2) : _Base(__e1, __e2) {}
627 };
628
629 template<class _Oper, class _Dom>
b714a419
PC
630 struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom>
631 : _BinBase1<_Oper, _Dom>
c13bea50
NS
632 {
633 typedef typename _Dom::value_type _Tp;
b714a419 634 typedef _BinBase1<_Oper, _Dom> _Base;
c13bea50 635 typedef typename _Base::value_type value_type;
ed6814f7 636
c13bea50
NS
637 _BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {}
638 };
ed6814f7 639
c13bea50 640 template<class _Oper, typename _Tp>
b714a419
PC
641 struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp>
642 : _BinBase2<_Oper, valarray<_Tp> >
c13bea50
NS
643 {
644 typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
645 typedef typename _Base::value_type value_type;
ed6814f7 646
c13bea50
NS
647 _BinClos(const valarray<_Tp>& __v, const _Tp& __t) : _Base(__v, __t) {}
648 };
649
650 template<class _Oper, typename _Tp>
b714a419
PC
651 struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp>
652 : _BinBase1<_Oper, valarray<_Tp> >
c13bea50 653 {
b714a419 654 typedef _BinBase1<_Oper, valarray<_Tp> > _Base;
c13bea50 655 typedef typename _Base::value_type value_type;
ed6814f7 656
c13bea50
NS
657 _BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {}
658 };
ed6814f7 659
c13bea50
NS
660 //
661 // slice_array closure.
662 //
b714a419
PC
663 template<typename _Dom>
664 class _SBase
665 {
c13bea50 666 public:
b714a419
PC
667 typedef typename _Dom::value_type value_type;
668
669 _SBase (const _Dom& __e, const slice& __s)
670 : _M_expr (__e), _M_slice (__s) {}
671
672 value_type
673 operator[] (size_t __i) const
674 { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; }
675
676 size_t
677 size() const
678 { return _M_slice.size (); }
c13bea50
NS
679
680 private:
b714a419
PC
681 const _Dom& _M_expr;
682 const slice& _M_slice;
c13bea50
NS
683 };
684
b714a419
PC
685 template<typename _Tp>
686 class _SBase<_Array<_Tp> >
687 {
c13bea50 688 public:
b714a419
PC
689 typedef _Tp value_type;
690
691 _SBase (_Array<_Tp> __a, const slice& __s)
692 : _M_array (__a._M_data+__s.start()), _M_size (__s.size()),
693 _M_stride (__s.stride()) {}
694
695 value_type
696 operator[] (size_t __i) const
697 { return _M_array._M_data[__i * _M_stride]; }
698
699 size_t
700 size() const
701 { return _M_size; }
c13bea50
NS
702
703 private:
b714a419
PC
704 const _Array<_Tp> _M_array;
705 const size_t _M_size;
706 const size_t _M_stride;
c13bea50
NS
707 };
708
b714a419
PC
709 template<class _Dom>
710 struct _SClos<_Expr, _Dom>
711 : _SBase<_Dom>
712 {
713 typedef _SBase<_Dom> _Base;
714 typedef typename _Base::value_type value_type;
715
716 _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {}
c13bea50
NS
717 };
718
b714a419
PC
719 template<typename _Tp>
720 struct _SClos<_ValArray, _Tp>
721 : _SBase<_Array<_Tp> >
722 {
723 typedef _SBase<_Array<_Tp> > _Base;
724 typedef _Tp value_type;
725
726 _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {}
c13bea50
NS
727 };
728
3cbc7af0 729_GLIBCXX_END_NAMESPACE
c13bea50 730
c13bea50 731#endif /* _CPP_VALARRAY_BEFORE_H */