gccxml_gem 0.9-x86-darwin-9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +75 -0
- data/bin/gccxml +0 -0
- data/bin/gccxml_cc1plus +0 -0
- data/gccxml.rb +44 -0
- data/share/doc/gccxml-0.9/Copyright.txt +55 -0
- data/share/doc/gccxml-0.9/gccxml.html +168 -0
- data/share/doc/gccxml-0.9/gccxml.txt +293 -0
- data/share/gccxml-0.9/GCC/2.95/algorithm +76 -0
- data/share/gccxml-0.9/GCC/2.95/bitset +17 -0
- data/share/gccxml-0.9/GCC/2.95/cctype +24 -0
- data/share/gccxml-0.9/GCC/2.95/clocale +14 -0
- data/share/gccxml-0.9/GCC/2.95/cmath +33 -0
- data/share/gccxml-0.9/GCC/2.95/complex +38 -0
- data/share/gccxml-0.9/GCC/2.95/csetjmp +13 -0
- data/share/gccxml-0.9/GCC/2.95/csignal +14 -0
- data/share/gccxml-0.9/GCC/2.95/cstdarg +12 -0
- data/share/gccxml-0.9/GCC/2.95/cstddef +13 -0
- data/share/gccxml-0.9/GCC/2.95/cstdio +55 -0
- data/share/gccxml-0.9/GCC/2.95/cstdlib +66 -0
- data/share/gccxml-0.9/GCC/2.95/cstring +34 -0
- data/share/gccxml-0.9/GCC/2.95/ctime +24 -0
- data/share/gccxml-0.9/GCC/2.95/cwchar +65 -0
- data/share/gccxml-0.9/GCC/2.95/cwctype +31 -0
- data/share/gccxml-0.9/GCC/2.95/deque +19 -0
- data/share/gccxml-0.9/GCC/2.95/exception +20 -0
- data/share/gccxml-0.9/GCC/2.95/fstream +23 -0
- data/share/gccxml-0.9/GCC/2.95/functional +64 -0
- data/share/gccxml-0.9/GCC/2.95/gccxml_bitset +1066 -0
- data/share/gccxml-0.9/GCC/2.95/iomanip +20 -0
- data/share/gccxml-0.9/GCC/2.95/iosfwd +20 -0
- data/share/gccxml-0.9/GCC/2.95/iostream +27 -0
- data/share/gccxml-0.9/GCC/2.95/iterator +39 -0
- data/share/gccxml-0.9/GCC/2.95/list +19 -0
- data/share/gccxml-0.9/GCC/2.95/map +20 -0
- data/share/gccxml-0.9/GCC/2.95/memory +21 -0
- data/share/gccxml-0.9/GCC/2.95/new +13 -0
- data/share/gccxml-0.9/GCC/2.95/numeric +15 -0
- data/share/gccxml-0.9/GCC/2.95/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/2.95/queue +20 -0
- data/share/gccxml-0.9/GCC/2.95/set +20 -0
- data/share/gccxml-0.9/GCC/2.95/sstream +24 -0
- data/share/gccxml-0.9/GCC/2.95/stack +19 -0
- data/share/gccxml-0.9/GCC/2.95/std/bastring.cc +524 -0
- data/share/gccxml-0.9/GCC/2.95/std/complext.h +397 -0
- data/share/gccxml-0.9/GCC/2.95/std/dcomplex.h +92 -0
- data/share/gccxml-0.9/GCC/2.95/std/fcomplex.h +88 -0
- data/share/gccxml-0.9/GCC/2.95/std/gslice_array.h +170 -0
- data/share/gccxml-0.9/GCC/2.95/std/indirect_array.h +157 -0
- data/share/gccxml-0.9/GCC/2.95/std/ldcomplex.h +96 -0
- data/share/gccxml-0.9/GCC/2.95/std/mask_array.h +154 -0
- data/share/gccxml-0.9/GCC/2.95/std/slice_array.h +156 -0
- data/share/gccxml-0.9/GCC/2.95/std/std_valarray.h +728 -0
- data/share/gccxml-0.9/GCC/2.95/std/straits.h +162 -0
- data/share/gccxml-0.9/GCC/2.95/std/valarray_meta.h +1035 -0
- data/share/gccxml-0.9/GCC/2.95/stdexcept +17 -0
- data/share/gccxml-0.9/GCC/2.95/stl_alloc.h +1057 -0
- data/share/gccxml-0.9/GCC/2.95/stl_bvector.h +836 -0
- data/share/gccxml-0.9/GCC/2.95/stl_deque.h +1699 -0
- data/share/gccxml-0.9/GCC/2.95/stl_list.h +843 -0
- data/share/gccxml-0.9/GCC/2.95/stl_tree.h +1331 -0
- data/share/gccxml-0.9/GCC/2.95/stl_vector.h +828 -0
- data/share/gccxml-0.9/GCC/2.95/string +26 -0
- data/share/gccxml-0.9/GCC/2.95/strstream +23 -0
- data/share/gccxml-0.9/GCC/2.95/typeinfo +11 -0
- data/share/gccxml-0.9/GCC/2.95/utility +25 -0
- data/share/gccxml-0.9/GCC/2.95/valarray +52 -0
- data/share/gccxml-0.9/GCC/2.95/vector +19 -0
- data/share/gccxml-0.9/GCC/2.96/sstream +305 -0
- data/share/gccxml-0.9/GCC/3.0/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.1/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.2/bits/fstream.tcc +500 -0
- data/share/gccxml-0.9/GCC/3.2/bits/istream.tcc +1207 -0
- data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.h +1810 -0
- data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.tcc +2397 -0
- data/share/gccxml-0.9/GCC/3.2/bits/messages_members.h +108 -0
- data/share/gccxml-0.9/GCC/3.2/bits/ostream.tcc +713 -0
- data/share/gccxml-0.9/GCC/3.2/bits/sstream.tcc +241 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_deque.h +1682 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_list.h +989 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_tree.h +1462 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_vector.h +1085 -0
- data/share/gccxml-0.9/GCC/3.2/bits/valarray_meta.h +1063 -0
- data/share/gccxml-0.9/GCC/3.2/fstream +579 -0
- data/share/gccxml-0.9/GCC/3.2/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.2/sstream +384 -0
- data/share/gccxml-0.9/GCC/3.3/bits/fstream.tcc +530 -0
- data/share/gccxml-0.9/GCC/3.3/bits/list.tcc +378 -0
- data/share/gccxml-0.9/GCC/3.3/bits/locale_facets.h +2050 -0
- data/share/gccxml-0.9/GCC/3.3/bits/messages_members.h +108 -0
- data/share/gccxml-0.9/GCC/3.3/bits/sstream.tcc +243 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_deque.h +1603 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_list.h +1167 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_tree.h +1462 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_vector.h +992 -0
- data/share/gccxml-0.9/GCC/3.3/bits/valarray_meta.h +1135 -0
- data/share/gccxml-0.9/GCC/3.3/fstream +842 -0
- data/share/gccxml-0.9/GCC/3.3/gccxml_builtins.h +22 -0
- data/share/gccxml-0.9/GCC/3.3/sstream +638 -0
- data/share/gccxml-0.9/GCC/3.4/gccxml_builtins.h +91 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_builtins.h +128 -0
- data/share/gccxml-0.9/GCC/4.1/bits/gthr-default.h +618 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_builtins.h +131 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_builtins.h +131 -0
- data/share/gccxml-0.9/GCC/find_flags +105 -0
- data/share/gccxml-0.9/Intel/find_flags +56 -0
- data/share/gccxml-0.9/Intel/pthread.h +16 -0
- data/share/gccxml-0.9/MIPSpro/7.3/exception +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/gccxml_mpro_internals.h +21 -0
- data/share/gccxml-0.9/MIPSpro/7.3/iomanip +161 -0
- data/share/gccxml-0.9/MIPSpro/7.3/ostream +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stddef.h +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_config.h +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_locale.h +17 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_monetary.h +14 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_numeric_facets.h +13 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_threads.h +11 -0
- data/share/gccxml-0.9/MIPSpro/7.3/string +18 -0
- data/share/gccxml-0.9/MIPSpro/find_flags +137 -0
- data/share/gccxml-0.9/Sun/5.8/adaptation.patch +168 -0
- data/share/gccxml-0.9/Sun/README +8 -0
- data/share/gccxml-0.9/Sun/adapt_headers.sh +24 -0
- data/share/gccxml-0.9/Sun/find_flags +69 -0
- data/share/gccxml-0.9/gccxml_config +2 -0
- data/share/gccxml-0.9/gccxml_find_flags +93 -0
- data/share/man/man1/gccxml.1 +246 -0
- metadata +204 -0
@@ -0,0 +1,1063 @@
|
|
1
|
+
// The template and inlines for the -*- C++ -*- internal _Meta class.
|
2
|
+
|
3
|
+
// Copyright (C) 1997, 1998, 1999, 2000, 2001 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
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
|
+
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
|
31
|
+
|
32
|
+
/** @file valarray_meta.h
|
33
|
+
* This is an internal header file, included by other library headers.
|
34
|
+
* You should not attempt to use it directly.
|
35
|
+
*/
|
36
|
+
|
37
|
+
#ifndef _CPP_VALARRAY_META_H
|
38
|
+
#define _CPP_VALARRAY_META_H 1
|
39
|
+
|
40
|
+
#pragma GCC system_header
|
41
|
+
|
42
|
+
namespace std
|
43
|
+
{
|
44
|
+
|
45
|
+
//
|
46
|
+
// Implementing a loosened valarray return value is tricky.
|
47
|
+
// First we need to meet 26.3.1/3: we should not add more than
|
48
|
+
// two levels of template nesting. Therefore we resort to template
|
49
|
+
// template to "flatten" loosened return value types.
|
50
|
+
// At some point we use partial specialization to remove one level
|
51
|
+
// template nesting due to _Expr<>
|
52
|
+
//
|
53
|
+
|
54
|
+
|
55
|
+
// This class is NOT defined. It doesn't need to.
|
56
|
+
template<typename _Tp1, typename _Tp2> class _Constant;
|
57
|
+
|
58
|
+
//
|
59
|
+
// Unary function application closure.
|
60
|
+
//
|
61
|
+
template<class _Dom> class _UnFunBase {
|
62
|
+
public:
|
63
|
+
typedef typename _Dom::value_type value_type;
|
64
|
+
typedef value_type _Vt;
|
65
|
+
|
66
|
+
_UnFunBase (const _Dom& __e, _Vt __f(_Vt))
|
67
|
+
: _M_expr(__e), _M_func(__f) {}
|
68
|
+
|
69
|
+
_Vt operator[] (size_t __i) const { return _M_func(_M_expr[__i]); }
|
70
|
+
size_t size () const { return _M_expr.size(); }
|
71
|
+
|
72
|
+
private:
|
73
|
+
const _Dom& _M_expr;
|
74
|
+
_Vt (*_M_func)(_Vt);
|
75
|
+
};
|
76
|
+
|
77
|
+
template<template<class, class> class _Meta, class _Dom>
|
78
|
+
class _UnFunClos;
|
79
|
+
|
80
|
+
template<class _Dom>
|
81
|
+
struct _UnFunClos<_Expr,_Dom> : _UnFunBase<_Dom> {
|
82
|
+
typedef _UnFunBase<_Dom> _Base;
|
83
|
+
typedef typename _Base::value_type value_type;
|
84
|
+
|
85
|
+
_UnFunClos (const _Dom& __e, value_type __f(value_type))
|
86
|
+
: _Base (__e, __f) {}
|
87
|
+
};
|
88
|
+
|
89
|
+
template<typename _Tp>
|
90
|
+
struct _UnFunClos<_ValArray,_Tp> : _UnFunBase<valarray<_Tp> > {
|
91
|
+
typedef _UnFunBase<valarray<_Tp> > _Base;
|
92
|
+
typedef typename _Base::value_type value_type;
|
93
|
+
|
94
|
+
_UnFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp))
|
95
|
+
: _Base (__v, __f) {}
|
96
|
+
};
|
97
|
+
|
98
|
+
//
|
99
|
+
// Binary function application closure.
|
100
|
+
//
|
101
|
+
template<template<class, class> class _Meta1,
|
102
|
+
template<class, class> class Meta2,
|
103
|
+
class _Dom1, class _Dom2> class _BinFunClos;
|
104
|
+
|
105
|
+
template<class _Dom1, class _Dom2> class _BinFunBase {
|
106
|
+
public:
|
107
|
+
typedef typename _Dom1::value_type value_type;
|
108
|
+
typedef value_type _Vt;
|
109
|
+
|
110
|
+
_BinFunBase (const _Dom1& __e1, const _Dom2& __e2,
|
111
|
+
_Vt __f (_Vt, _Vt))
|
112
|
+
: _M_expr1 (__e1), _M_expr2 (__e2), _M_func (__f) {}
|
113
|
+
|
114
|
+
value_type operator[] (size_t __i) const
|
115
|
+
{ return _M_func (_M_expr1[__i], _M_expr2[__i]); }
|
116
|
+
size_t size () const { return _M_expr1.size (); }
|
117
|
+
|
118
|
+
private:
|
119
|
+
const _Dom1& _M_expr1;
|
120
|
+
const _Dom2& _M_expr2;
|
121
|
+
_Vt (*_M_func)(_Vt, _Vt);
|
122
|
+
};
|
123
|
+
|
124
|
+
template<class _Dom> class _BinFunBase1 {
|
125
|
+
public:
|
126
|
+
typedef typename _Dom::value_type value_type ;
|
127
|
+
typedef value_type _Vt;
|
128
|
+
|
129
|
+
_BinFunBase1 (const _Vt& __c, const _Dom& __e, _Vt __f(_Vt, _Vt))
|
130
|
+
: _M_expr1 (__c), _M_expr2 (__e), _M_func (__f) {}
|
131
|
+
|
132
|
+
value_type operator[] (size_t __i) const
|
133
|
+
{ return _M_func (_M_expr1, _M_expr2[__i]); }
|
134
|
+
size_t size () const { return _M_expr2.size (); }
|
135
|
+
|
136
|
+
private:
|
137
|
+
const _Vt& _M_expr1;
|
138
|
+
const _Dom& _M_expr2;
|
139
|
+
_Vt (*_M_func)(_Vt, _Vt);
|
140
|
+
};
|
141
|
+
|
142
|
+
template<class _Dom> class _BinFunBase2 {
|
143
|
+
public:
|
144
|
+
typedef typename _Dom::value_type value_type;
|
145
|
+
typedef value_type _Vt;
|
146
|
+
|
147
|
+
_BinFunBase2 (const _Dom& __e, const _Vt& __c, _Vt __f(_Vt, _Vt))
|
148
|
+
: _M_expr1 (__e), _M_expr2 (__c), _M_func (__f) {}
|
149
|
+
|
150
|
+
value_type operator[] (size_t __i) const
|
151
|
+
{ return _M_func (_M_expr1[__i], _M_expr2); }
|
152
|
+
size_t size () const { return _M_expr1.size (); }
|
153
|
+
|
154
|
+
private:
|
155
|
+
const _Dom& _M_expr1;
|
156
|
+
const _Vt& _M_expr2;
|
157
|
+
_Vt (*_M_func)(_Vt, _Vt);
|
158
|
+
};
|
159
|
+
|
160
|
+
template<class _Dom1, class _Dom2>
|
161
|
+
struct _BinFunClos<_Expr,_Expr,_Dom1,_Dom2> : _BinFunBase<_Dom1,_Dom2> {
|
162
|
+
typedef _BinFunBase<_Dom1,_Dom2> _Base;
|
163
|
+
typedef typename _Base::value_type value_type;
|
164
|
+
typedef value_type _Tp;
|
165
|
+
|
166
|
+
_BinFunClos (const _Dom1& __e1, const _Dom2& __e2,
|
167
|
+
_Tp __f(_Tp, _Tp))
|
168
|
+
: _Base (__e1, __e2, __f) {}
|
169
|
+
};
|
170
|
+
|
171
|
+
template<typename _Tp>
|
172
|
+
struct _BinFunClos<_ValArray,_ValArray,_Tp,_Tp>
|
173
|
+
: _BinFunBase<valarray<_Tp>, valarray<_Tp> > {
|
174
|
+
typedef _BinFunBase<valarray<_Tp>, valarray<_Tp> > _Base;
|
175
|
+
typedef _Tp value_type;
|
176
|
+
|
177
|
+
_BinFunClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w,
|
178
|
+
_Tp __f(_Tp, _Tp))
|
179
|
+
: _Base (__v, __w, __f) {}
|
180
|
+
};
|
181
|
+
|
182
|
+
template<class _Dom>
|
183
|
+
struct _BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type>
|
184
|
+
: _BinFunBase<_Dom,valarray<typename _Dom::value_type> > {
|
185
|
+
typedef typename _Dom::value_type _Tp;
|
186
|
+
typedef _BinFunBase<_Dom,valarray<_Tp> > _Base;
|
187
|
+
typedef _Tp value_type;
|
188
|
+
|
189
|
+
_BinFunClos (const _Dom& __e, const valarray<_Tp>& __v,
|
190
|
+
_Tp __f(_Tp, _Tp))
|
191
|
+
: _Base (__e, __v, __f) {}
|
192
|
+
};
|
193
|
+
|
194
|
+
template<class _Dom>
|
195
|
+
struct _BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>
|
196
|
+
: _BinFunBase<valarray<typename _Dom::value_type>,_Dom> {
|
197
|
+
typedef typename _Dom::value_type _Tp;
|
198
|
+
typedef _BinFunBase<_Dom,valarray<_Tp> > _Base;
|
199
|
+
typedef _Tp value_type;
|
200
|
+
|
201
|
+
_BinFunClos (const valarray<_Tp>& __v, const _Dom& __e,
|
202
|
+
_Tp __f(_Tp, _Tp))
|
203
|
+
: _Base (__v, __e, __f) {}
|
204
|
+
};
|
205
|
+
|
206
|
+
template<class _Dom>
|
207
|
+
struct _BinFunClos<_Expr,_Constant,_Dom,typename _Dom::value_type>
|
208
|
+
: _BinFunBase2<_Dom> {
|
209
|
+
typedef typename _Dom::value_type _Tp;
|
210
|
+
typedef _Tp value_type;
|
211
|
+
typedef _BinFunBase2<_Dom> _Base;
|
212
|
+
|
213
|
+
_BinFunClos (const _Dom& __e, const _Tp& __t, _Tp __f (_Tp, _Tp))
|
214
|
+
: _Base (__e, __t, __f) {}
|
215
|
+
};
|
216
|
+
|
217
|
+
template<class _Dom>
|
218
|
+
struct _BinFunClos<_Constant,_Expr,_Dom,typename _Dom::value_type>
|
219
|
+
: _BinFunBase1<_Dom> {
|
220
|
+
typedef typename _Dom::value_type _Tp;
|
221
|
+
typedef _Tp value_type;
|
222
|
+
typedef _BinFunBase1<_Dom> _Base;
|
223
|
+
|
224
|
+
_BinFunClos (const _Tp& __t, const _Dom& __e, _Tp __f (_Tp, _Tp))
|
225
|
+
: _Base (__t, __e, __f) {}
|
226
|
+
};
|
227
|
+
|
228
|
+
template<typename _Tp>
|
229
|
+
struct _BinFunClos<_ValArray,_Constant,_Tp,_Tp>
|
230
|
+
: _BinFunBase2<valarray<_Tp> > {
|
231
|
+
typedef _BinFunBase2<valarray<_Tp> > _Base;
|
232
|
+
typedef _Tp value_type;
|
233
|
+
|
234
|
+
_BinFunClos (const valarray<_Tp>& __v, const _Tp& __t,
|
235
|
+
_Tp __f(_Tp, _Tp))
|
236
|
+
: _Base (__v, __t, __f) {}
|
237
|
+
};
|
238
|
+
|
239
|
+
template<typename _Tp>
|
240
|
+
struct _BinFunClos<_Constant,_ValArray,_Tp,_Tp>
|
241
|
+
: _BinFunBase1<valarray<_Tp> > {
|
242
|
+
typedef _BinFunBase1<valarray<_Tp> > _Base;
|
243
|
+
typedef _Tp value_type;
|
244
|
+
|
245
|
+
_BinFunClos (const _Tp& __t, const valarray<_Tp>& __v,
|
246
|
+
_Tp __f (_Tp, _Tp))
|
247
|
+
: _Base (__t, __v, __f) {}
|
248
|
+
};
|
249
|
+
|
250
|
+
//
|
251
|
+
// Apply function taking a value/const reference closure
|
252
|
+
//
|
253
|
+
|
254
|
+
template<typename _Dom, typename _Arg> class _FunBase {
|
255
|
+
public:
|
256
|
+
typedef typename _Dom::value_type value_type;
|
257
|
+
|
258
|
+
_FunBase (const _Dom& __e, value_type __f(_Arg))
|
259
|
+
: _M_expr (__e), _M_func (__f) {}
|
260
|
+
|
261
|
+
value_type operator[] (size_t __i) const
|
262
|
+
{ return _M_func (_M_expr[__i]); }
|
263
|
+
size_t size() const { return _M_expr.size ();}
|
264
|
+
|
265
|
+
private:
|
266
|
+
const _Dom& _M_expr;
|
267
|
+
value_type (*_M_func)(_Arg);
|
268
|
+
};
|
269
|
+
|
270
|
+
template<class _Dom>
|
271
|
+
struct _ValFunClos<_Expr,_Dom>
|
272
|
+
: _FunBase<_Dom, typename _Dom::value_type> {
|
273
|
+
typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
|
274
|
+
typedef typename _Base::value_type value_type;
|
275
|
+
typedef value_type _Tp;
|
276
|
+
|
277
|
+
_ValFunClos (const _Dom& __e, _Tp __f (_Tp)) : _Base (__e, __f) {}
|
278
|
+
};
|
279
|
+
|
280
|
+
template<typename _Tp>
|
281
|
+
struct _ValFunClos<_ValArray,_Tp>
|
282
|
+
: _FunBase<valarray<_Tp>, _Tp> {
|
283
|
+
typedef _FunBase<valarray<_Tp>, _Tp> _Base;
|
284
|
+
typedef _Tp value_type;
|
285
|
+
|
286
|
+
_ValFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp))
|
287
|
+
: _Base (__v, __f) {}
|
288
|
+
};
|
289
|
+
|
290
|
+
template<class _Dom>
|
291
|
+
struct _RefFunClos<_Expr,_Dom> :
|
292
|
+
_FunBase<_Dom, const typename _Dom::value_type&> {
|
293
|
+
typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
|
294
|
+
typedef typename _Base::value_type value_type;
|
295
|
+
typedef value_type _Tp;
|
296
|
+
|
297
|
+
_RefFunClos (const _Dom& __e, _Tp __f (const _Tp&))
|
298
|
+
: _Base (__e, __f) {}
|
299
|
+
};
|
300
|
+
|
301
|
+
template<typename _Tp>
|
302
|
+
struct _RefFunClos<_ValArray,_Tp>
|
303
|
+
: _FunBase<valarray<_Tp>, const _Tp&> {
|
304
|
+
typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
|
305
|
+
typedef _Tp value_type;
|
306
|
+
|
307
|
+
_RefFunClos (const valarray<_Tp>& __v, _Tp __f(const _Tp&))
|
308
|
+
: _Base (__v, __f) {}
|
309
|
+
};
|
310
|
+
|
311
|
+
//
|
312
|
+
// Unary expression closure.
|
313
|
+
//
|
314
|
+
|
315
|
+
template<template<class> class _Oper, typename _Arg>
|
316
|
+
class _UnBase {
|
317
|
+
public:
|
318
|
+
typedef _Oper<typename _Arg::value_type> _Op;
|
319
|
+
typedef typename _Op::result_type value_type;
|
320
|
+
|
321
|
+
_UnBase (const _Arg& __e) : _M_expr(__e) {}
|
322
|
+
value_type operator[] (size_t) const;
|
323
|
+
size_t size () const { return _M_expr.size (); }
|
324
|
+
|
325
|
+
private:
|
326
|
+
const _Arg& _M_expr;
|
327
|
+
};
|
328
|
+
|
329
|
+
template<template<class> class _Oper, typename _Arg>
|
330
|
+
inline typename _UnBase<_Oper, _Arg>::value_type
|
331
|
+
_UnBase<_Oper, _Arg>::operator[] (size_t __i) const
|
332
|
+
{ return _Op() (_M_expr[__i]); }
|
333
|
+
|
334
|
+
template<template<class> class _Oper, class _Dom>
|
335
|
+
struct _UnClos<_Oper, _Expr, _Dom> : _UnBase<_Oper, _Dom> {
|
336
|
+
typedef _Dom _Arg;
|
337
|
+
typedef _UnBase<_Oper, _Dom> _Base;
|
338
|
+
typedef typename _Base::value_type value_type;
|
339
|
+
|
340
|
+
_UnClos (const _Arg& __e) : _Base(__e) {}
|
341
|
+
};
|
342
|
+
|
343
|
+
template<template<class> class _Oper, typename _Tp>
|
344
|
+
struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > {
|
345
|
+
typedef valarray<_Tp> _Arg;
|
346
|
+
typedef _UnBase<_Oper, valarray<_Tp> > _Base;
|
347
|
+
typedef typename _Base::value_type value_type;
|
348
|
+
|
349
|
+
_UnClos (const _Arg& __e) : _Base(__e) {}
|
350
|
+
};
|
351
|
+
|
352
|
+
|
353
|
+
//
|
354
|
+
// Binary expression closure.
|
355
|
+
//
|
356
|
+
|
357
|
+
template<template<class> class _Oper,
|
358
|
+
typename _FirstArg, typename _SecondArg>
|
359
|
+
class _BinBase {
|
360
|
+
public:
|
361
|
+
typedef _Oper<typename _FirstArg::value_type> _Op;
|
362
|
+
typedef typename _Op::result_type value_type;
|
363
|
+
|
364
|
+
_BinBase (const _FirstArg& __e1, const _SecondArg& __e2)
|
365
|
+
: _M_expr1 (__e1), _M_expr2 (__e2) {}
|
366
|
+
value_type operator[] (size_t) const;
|
367
|
+
size_t size () const { return _M_expr1.size (); }
|
368
|
+
|
369
|
+
private:
|
370
|
+
const _FirstArg& _M_expr1;
|
371
|
+
const _SecondArg& _M_expr2;
|
372
|
+
};
|
373
|
+
|
374
|
+
template<template<class> class _Oper,
|
375
|
+
typename _FirstArg, typename _SecondArg>
|
376
|
+
inline typename _BinBase<_Oper,_FirstArg,_SecondArg>::value_type
|
377
|
+
_BinBase<_Oper,_FirstArg,_SecondArg>::operator[] (size_t __i) const
|
378
|
+
{ return _Op() (_M_expr1[__i], _M_expr2[__i]); }
|
379
|
+
|
380
|
+
|
381
|
+
template<template<class> class _Oper, class _Clos>
|
382
|
+
class _BinBase2 {
|
383
|
+
public:
|
384
|
+
typedef typename _Clos::value_type _Vt;
|
385
|
+
typedef _Oper<_Vt> _Op;
|
386
|
+
typedef typename _Op::result_type value_type;
|
387
|
+
|
388
|
+
_BinBase2 (const _Clos& __e, const _Vt& __t)
|
389
|
+
: _M_expr1 (__e), _M_expr2 (__t) {}
|
390
|
+
value_type operator[] (size_t) const;
|
391
|
+
size_t size () const { return _M_expr1.size (); }
|
392
|
+
|
393
|
+
private:
|
394
|
+
const _Clos& _M_expr1;
|
395
|
+
const _Vt& _M_expr2;
|
396
|
+
};
|
397
|
+
|
398
|
+
template<template<class> class _Oper, class _Clos>
|
399
|
+
inline typename _BinBase2<_Oper,_Clos>::value_type
|
400
|
+
_BinBase2<_Oper,_Clos>::operator[] (size_t __i) const
|
401
|
+
{ return _Op() (_M_expr1[__i], _M_expr2); }
|
402
|
+
|
403
|
+
|
404
|
+
template<template<class> class _Oper, class _Clos>
|
405
|
+
class _BinBase1 {
|
406
|
+
public:
|
407
|
+
typedef typename _Clos::value_type _Vt;
|
408
|
+
typedef _Oper<_Vt> _Op;
|
409
|
+
typedef typename _Op::result_type value_type;
|
410
|
+
|
411
|
+
_BinBase1 (const _Vt& __t, const _Clos& __e)
|
412
|
+
: _M_expr1 (__t), _M_expr2 (__e) {}
|
413
|
+
value_type operator[] (size_t) const;
|
414
|
+
size_t size () const { return _M_expr2.size (); }
|
415
|
+
|
416
|
+
private:
|
417
|
+
const _Vt& _M_expr1;
|
418
|
+
const _Clos& _M_expr2;
|
419
|
+
};
|
420
|
+
|
421
|
+
template<template<class> class _Oper, class _Clos>
|
422
|
+
inline typename
|
423
|
+
_BinBase1<_Oper,_Clos>::value_type
|
424
|
+
_BinBase1<_Oper,_Clos>:: operator[] (size_t __i) const
|
425
|
+
{ return _Op() (_M_expr1, _M_expr2[__i]); }
|
426
|
+
|
427
|
+
|
428
|
+
template<template<class> class _Oper, class _Dom1, class _Dom2>
|
429
|
+
struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
|
430
|
+
: _BinBase<_Oper,_Dom1,_Dom2> {
|
431
|
+
typedef _BinBase<_Oper,_Dom1,_Dom2> _Base;
|
432
|
+
typedef typename _Base::value_type value_type;
|
433
|
+
|
434
|
+
_BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
|
435
|
+
};
|
436
|
+
|
437
|
+
template<template<class> class _Oper, typename _Tp>
|
438
|
+
struct _BinClos<_Oper,_ValArray,_ValArray,_Tp,_Tp>
|
439
|
+
: _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > {
|
440
|
+
typedef _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > _Base;
|
441
|
+
typedef _Tp value_type;
|
442
|
+
|
443
|
+
_BinClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w)
|
444
|
+
: _Base (__v, __w) {}
|
445
|
+
};
|
446
|
+
|
447
|
+
template<template<class> class _Oper, class _Dom>
|
448
|
+
struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type>
|
449
|
+
: _BinBase<_Oper,_Dom,valarray<typename _Dom::value_type> > {
|
450
|
+
typedef typename _Dom::value_type _Tp;
|
451
|
+
typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
|
452
|
+
typedef typename _Base::value_type value_type;
|
453
|
+
|
454
|
+
_BinClos(const _Dom& __e1, const valarray<_Tp>& __e2)
|
455
|
+
: _Base (__e1, __e2) {}
|
456
|
+
};
|
457
|
+
|
458
|
+
template<template<class> class _Oper, class _Dom>
|
459
|
+
struct _BinClos<_Oper,_ValArray,_Expr,typename _Dom::value_type,_Dom>
|
460
|
+
: _BinBase<_Oper,valarray<typename _Dom::value_type>,_Dom> {
|
461
|
+
typedef typename _Dom::value_type _Tp;
|
462
|
+
typedef _BinBase<_Oper,valarray<_Tp>,_Dom> _Base;
|
463
|
+
typedef typename _Base::value_type value_type;
|
464
|
+
|
465
|
+
_BinClos (const valarray<_Tp>& __e1, const _Dom& __e2)
|
466
|
+
: _Base (__e1, __e2) {}
|
467
|
+
};
|
468
|
+
|
469
|
+
template<template<class> class _Oper, class _Dom>
|
470
|
+
struct _BinClos<_Oper,_Expr,_Constant,_Dom,typename _Dom::value_type>
|
471
|
+
: _BinBase2<_Oper,_Dom> {
|
472
|
+
typedef typename _Dom::value_type _Tp;
|
473
|
+
typedef _BinBase2<_Oper,_Dom> _Base;
|
474
|
+
typedef typename _Base::value_type value_type;
|
475
|
+
|
476
|
+
_BinClos (const _Dom& __e1, const _Tp& __e2) : _Base (__e1, __e2) {}
|
477
|
+
};
|
478
|
+
|
479
|
+
template<template<class> class _Oper, class _Dom>
|
480
|
+
struct _BinClos<_Oper,_Constant,_Expr,typename _Dom::value_type,_Dom>
|
481
|
+
: _BinBase1<_Oper,_Dom> {
|
482
|
+
typedef typename _Dom::value_type _Tp;
|
483
|
+
typedef _BinBase1<_Oper,_Dom> _Base;
|
484
|
+
typedef typename _Base::value_type value_type;
|
485
|
+
|
486
|
+
_BinClos (const _Tp& __e1, const _Dom& __e2) : _Base (__e1, __e2) {}
|
487
|
+
};
|
488
|
+
|
489
|
+
template<template<class> class _Oper, typename _Tp>
|
490
|
+
struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp>
|
491
|
+
: _BinBase2<_Oper,valarray<_Tp> > {
|
492
|
+
typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
|
493
|
+
typedef typename _Base::value_type value_type;
|
494
|
+
|
495
|
+
_BinClos (const valarray<_Tp>& __v, const _Tp& __t)
|
496
|
+
: _Base (__v, __t) {}
|
497
|
+
};
|
498
|
+
|
499
|
+
template<template<class> class _Oper, typename _Tp>
|
500
|
+
struct _BinClos<_Oper,_Constant,_ValArray,_Tp,_Tp>
|
501
|
+
: _BinBase1<_Oper,valarray<_Tp> > {
|
502
|
+
typedef _BinBase1<_Oper,valarray<_Tp> > _Base;
|
503
|
+
typedef typename _Base::value_type value_type;
|
504
|
+
|
505
|
+
_BinClos (const _Tp& __t, const valarray<_Tp>& __v)
|
506
|
+
: _Base (__t, __v) {}
|
507
|
+
};
|
508
|
+
|
509
|
+
|
510
|
+
//
|
511
|
+
// slice_array closure.
|
512
|
+
//
|
513
|
+
template<typename _Dom> class _SBase {
|
514
|
+
public:
|
515
|
+
typedef typename _Dom::value_type value_type;
|
516
|
+
|
517
|
+
_SBase (const _Dom& __e, const slice& __s)
|
518
|
+
: _M_expr (__e), _M_slice (__s) {}
|
519
|
+
value_type operator[] (size_t __i) const;
|
520
|
+
size_t size() const;
|
521
|
+
|
522
|
+
private:
|
523
|
+
const _Dom& _M_expr;
|
524
|
+
const slice& _M_slice;
|
525
|
+
};
|
526
|
+
|
527
|
+
template<typename _Tp> class _SBase<_Array<_Tp> > {
|
528
|
+
public:
|
529
|
+
typedef _Tp value_type;
|
530
|
+
|
531
|
+
_SBase (_Array<_Tp> __a, const slice& __s);
|
532
|
+
value_type operator[] (size_t __i) const;
|
533
|
+
size_t size() const;
|
534
|
+
|
535
|
+
private:
|
536
|
+
const _Array<_Tp> _M_array;
|
537
|
+
const size_t _M_size;
|
538
|
+
const size_t _M_stride;
|
539
|
+
};
|
540
|
+
|
541
|
+
template<class _Dom> struct _SClos<_Expr,_Dom> : _SBase<_Dom> {
|
542
|
+
typedef _SBase<_Dom> _Base;
|
543
|
+
typedef typename _Base::value_type value_type;
|
544
|
+
|
545
|
+
_SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {}
|
546
|
+
};
|
547
|
+
|
548
|
+
template<typename _Tp>
|
549
|
+
struct _SClos<_ValArray,_Tp> : _SBase<_Array<_Tp> > {
|
550
|
+
typedef _SBase<_Array<_Tp> > _Base;
|
551
|
+
typedef _Tp value_type;
|
552
|
+
|
553
|
+
_SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {}
|
554
|
+
};
|
555
|
+
|
556
|
+
//
|
557
|
+
// gslice_array closure.
|
558
|
+
//
|
559
|
+
template<class _Dom> class _GBase {
|
560
|
+
public:
|
561
|
+
typedef typename _Dom::value_type value_type;
|
562
|
+
|
563
|
+
_GBase (const _Dom& __e, const valarray<size_t>& __i)
|
564
|
+
: _M_expr (__e), _M_index(__i) {}
|
565
|
+
value_type operator[] (size_t __i) const;
|
566
|
+
size_t size () const;
|
567
|
+
|
568
|
+
private:
|
569
|
+
const _Dom& _M_expr;
|
570
|
+
const valarray<size_t>& _M_index;
|
571
|
+
};
|
572
|
+
|
573
|
+
template<typename _Tp> class _GBase<_Array<_Tp> > {
|
574
|
+
public:
|
575
|
+
typedef _Tp value_type;
|
576
|
+
|
577
|
+
_GBase (_Array<_Tp> __a, const valarray<size_t>& __i)
|
578
|
+
: _M_array (__a), _M_index(__i) {}
|
579
|
+
value_type operator[] (size_t __i) const;
|
580
|
+
size_t size () const;
|
581
|
+
|
582
|
+
private:
|
583
|
+
const _Array<_Tp> _M_array;
|
584
|
+
const valarray<size_t>& _M_index;
|
585
|
+
};
|
586
|
+
|
587
|
+
template<class _Dom> struct _GClos<_Expr,_Dom> : _GBase<_Dom> {
|
588
|
+
typedef _GBase<_Dom> _Base;
|
589
|
+
typedef typename _Base::value_type value_type;
|
590
|
+
|
591
|
+
_GClos (const _Dom& __e, const valarray<size_t>& __i)
|
592
|
+
: _Base (__e, __i) {}
|
593
|
+
};
|
594
|
+
|
595
|
+
template<typename _Tp>
|
596
|
+
struct _GClos<_ValArray,_Tp> : _GBase<_Array<_Tp> > {
|
597
|
+
typedef _GBase<_Array<_Tp> > _Base;
|
598
|
+
typedef typename _Base::value_type value_type;
|
599
|
+
|
600
|
+
_GClos (_Array<_Tp> __a, const valarray<size_t>& __i)
|
601
|
+
: _Base (__a, __i) {}
|
602
|
+
};
|
603
|
+
|
604
|
+
//
|
605
|
+
// indirect_array closure
|
606
|
+
//
|
607
|
+
|
608
|
+
template<class _Dom> class _IBase {
|
609
|
+
public:
|
610
|
+
typedef typename _Dom::value_type value_type;
|
611
|
+
|
612
|
+
_IBase (const _Dom& __e, const valarray<size_t>& __i)
|
613
|
+
: _M_expr (__e), _M_index (__i) {}
|
614
|
+
value_type operator[] (size_t __i) const;
|
615
|
+
size_t size() const;
|
616
|
+
|
617
|
+
private:
|
618
|
+
const _Dom& _M_expr;
|
619
|
+
const valarray<size_t>& _M_index;
|
620
|
+
};
|
621
|
+
|
622
|
+
template<class _Dom> struct _IClos<_Expr,_Dom> : _IBase<_Dom> {
|
623
|
+
typedef _IBase<_Dom> _Base;
|
624
|
+
typedef typename _Base::value_type value_type;
|
625
|
+
|
626
|
+
_IClos (const _Dom& __e, const valarray<size_t>& __i)
|
627
|
+
: _Base (__e, __i) {}
|
628
|
+
};
|
629
|
+
|
630
|
+
template<typename _Tp>
|
631
|
+
struct _IClos<_ValArray,_Tp> : _IBase<valarray<_Tp> > {
|
632
|
+
typedef _IBase<valarray<_Tp> > _Base;
|
633
|
+
typedef _Tp value_type;
|
634
|
+
|
635
|
+
_IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i)
|
636
|
+
: _Base (__a, __i) {}
|
637
|
+
};
|
638
|
+
|
639
|
+
//
|
640
|
+
// class _Expr
|
641
|
+
//
|
642
|
+
template<class _Clos, typename _Tp> class _Expr {
|
643
|
+
public:
|
644
|
+
typedef _Tp value_type;
|
645
|
+
|
646
|
+
_Expr (const _Clos&);
|
647
|
+
|
648
|
+
const _Clos& operator() () const;
|
649
|
+
|
650
|
+
value_type operator[] (size_t) const;
|
651
|
+
valarray<value_type> operator[] (slice) const;
|
652
|
+
valarray<value_type> operator[] (const gslice&) const;
|
653
|
+
valarray<value_type> operator[] (const valarray<bool>&) const;
|
654
|
+
valarray<value_type> operator[] (const valarray<size_t>&) const;
|
655
|
+
|
656
|
+
_Expr<_UnClos<_Unary_plus,std::_Expr,_Clos>, value_type>
|
657
|
+
operator+ () const;
|
658
|
+
|
659
|
+
_Expr<_UnClos<negate,std::_Expr,_Clos>, value_type>
|
660
|
+
operator- () const;
|
661
|
+
|
662
|
+
_Expr<_UnClos<_Bitwise_not,std::_Expr,_Clos>, value_type>
|
663
|
+
operator~ () const;
|
664
|
+
|
665
|
+
_Expr<_UnClos<logical_not,std::_Expr,_Clos>, bool>
|
666
|
+
operator! () const;
|
667
|
+
|
668
|
+
size_t size () const;
|
669
|
+
value_type sum () const;
|
670
|
+
|
671
|
+
valarray<value_type> shift (int) const;
|
672
|
+
valarray<value_type> cshift (int) const;
|
673
|
+
|
674
|
+
value_type min() const;
|
675
|
+
value_type max() const;
|
676
|
+
|
677
|
+
valarray<value_type> apply(value_type (*) (const value_type&)) const;
|
678
|
+
valarray<value_type> apply(value_type (*) (value_type)) const;
|
679
|
+
|
680
|
+
private:
|
681
|
+
const _Clos _M_closure;
|
682
|
+
};
|
683
|
+
|
684
|
+
template<class _Clos, typename _Tp>
|
685
|
+
inline
|
686
|
+
_Expr<_Clos,_Tp>::_Expr (const _Clos& __c) : _M_closure(__c) {}
|
687
|
+
|
688
|
+
template<class _Clos, typename _Tp>
|
689
|
+
inline const _Clos&
|
690
|
+
_Expr<_Clos,_Tp>::operator() () const
|
691
|
+
{ return _M_closure; }
|
692
|
+
|
693
|
+
template<class _Clos, typename _Tp>
|
694
|
+
inline _Tp
|
695
|
+
_Expr<_Clos,_Tp>::operator[] (size_t __i) const
|
696
|
+
{ return _M_closure[__i]; }
|
697
|
+
|
698
|
+
template<class _Clos, typename _Tp>
|
699
|
+
inline valarray<_Tp>
|
700
|
+
_Expr<_Clos,_Tp>::operator[] (const gslice& __gs) const
|
701
|
+
{ return _M_closure[__gs]; }
|
702
|
+
|
703
|
+
template<class _Clos, typename _Tp>
|
704
|
+
inline valarray<_Tp>
|
705
|
+
_Expr<_Clos,_Tp>::operator[] (const valarray<bool>& __m) const
|
706
|
+
{ return _M_closure[__m]; }
|
707
|
+
|
708
|
+
template<class _Clos, typename _Tp>
|
709
|
+
inline valarray<_Tp>
|
710
|
+
_Expr<_Clos,_Tp>::operator[] (const valarray<size_t>& __i) const
|
711
|
+
{ return _M_closure[__i]; }
|
712
|
+
|
713
|
+
template<class _Clos, typename _Tp>
|
714
|
+
inline size_t
|
715
|
+
_Expr<_Clos,_Tp>::size () const { return _M_closure.size (); }
|
716
|
+
|
717
|
+
template<class _Clos, typename _Tp>
|
718
|
+
inline valarray<_Tp>
|
719
|
+
_Expr<_Clos, _Tp>::shift(int __n) const
|
720
|
+
{ return valarray<_Tp>(_M_closure).shift(__n); }
|
721
|
+
|
722
|
+
template<class _Clos, typename _Tp>
|
723
|
+
inline valarray<_Tp>
|
724
|
+
_Expr<_Clos, _Tp>::cshift(int __n) const
|
725
|
+
{ return valarray<_Tp>(_M_closure).cshift(__n); }
|
726
|
+
|
727
|
+
template<class _Clos, typename _Tp>
|
728
|
+
inline valarray<_Tp>
|
729
|
+
_Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const
|
730
|
+
{ return valarray<_Tp>(_M_closure).apply(__f); }
|
731
|
+
|
732
|
+
template<class _Clos, typename _Tp>
|
733
|
+
inline valarray<_Tp>
|
734
|
+
_Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const
|
735
|
+
{ return valarray<_Tp>(_M_closure).apply(__f); }
|
736
|
+
|
737
|
+
// XXX: replace this with a more robust summation algorithm.
|
738
|
+
template<class _Clos, typename _Tp>
|
739
|
+
inline _Tp
|
740
|
+
_Expr<_Clos,_Tp>::sum () const
|
741
|
+
{
|
742
|
+
size_t __n = _M_closure.size();
|
743
|
+
if (__n == 0) return _Tp();
|
744
|
+
else {
|
745
|
+
_Tp __s = _M_closure[--__n];
|
746
|
+
while (__n != 0) __s += _M_closure[--__n];
|
747
|
+
return __s;
|
748
|
+
}
|
749
|
+
}
|
750
|
+
|
751
|
+
template<class _Clos, typename _Tp>
|
752
|
+
inline _Tp
|
753
|
+
_Expr<_Clos, _Tp>::min() const
|
754
|
+
{ return __valarray_min(_M_closure); }
|
755
|
+
|
756
|
+
template<class _Clos, typename _Tp>
|
757
|
+
inline _Tp
|
758
|
+
_Expr<_Clos, _Tp>::max() const
|
759
|
+
{ return __valarray_max(_M_closure); }
|
760
|
+
|
761
|
+
template<class _Dom, typename _Tp>
|
762
|
+
inline _Expr<_UnClos<logical_not,_Expr,_Dom>, bool>
|
763
|
+
_Expr<_Dom,_Tp>::operator! () const
|
764
|
+
{
|
765
|
+
typedef _UnClos<logical_not,std::_Expr,_Dom> _Closure;
|
766
|
+
return _Expr<_Closure,_Tp> (_Closure(this->_M_closure));
|
767
|
+
}
|
768
|
+
|
769
|
+
#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \
|
770
|
+
template<class _Dom, typename _Tp> \
|
771
|
+
inline _Expr<_UnClos<_Name,std::_Expr,_Dom>,_Tp> \
|
772
|
+
_Expr<_Dom,_Tp>::operator _Op () const \
|
773
|
+
{ \
|
774
|
+
typedef _UnClos<_Name,std::_Expr,_Dom> _Closure; \
|
775
|
+
return _Expr<_Closure,_Tp> (_Closure (this->_M_closure)); \
|
776
|
+
}
|
777
|
+
|
778
|
+
_DEFINE_EXPR_UNARY_OPERATOR(+, _Unary_plus)
|
779
|
+
_DEFINE_EXPR_UNARY_OPERATOR(-, negate)
|
780
|
+
_DEFINE_EXPR_UNARY_OPERATOR(~, _Bitwise_not)
|
781
|
+
|
782
|
+
#undef _DEFINE_EXPR_UNARY_OPERATOR
|
783
|
+
|
784
|
+
|
785
|
+
#define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \
|
786
|
+
template<class _Dom1, class _Dom2> \
|
787
|
+
inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \
|
788
|
+
typename _Name<typename _Dom1::value_type>::result_type> \
|
789
|
+
operator _Op (const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
|
790
|
+
const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
|
791
|
+
{ \
|
792
|
+
typedef typename _Dom1::value_type _Arg; \
|
793
|
+
typedef typename _Name<_Arg>::result_type _Value; \
|
794
|
+
typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
|
795
|
+
return _Expr<_Closure,_Value> (_Closure (__v (), __w ())); \
|
796
|
+
} \
|
797
|
+
\
|
798
|
+
template<class _Dom> \
|
799
|
+
inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \
|
800
|
+
typename _Name<typename _Dom::value_type>::result_type> \
|
801
|
+
operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __v, \
|
802
|
+
const typename _Dom::value_type& __t) \
|
803
|
+
{ \
|
804
|
+
typedef typename _Dom::value_type _Arg; \
|
805
|
+
typedef typename _Name<_Arg>::result_type _Value; \
|
806
|
+
typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
|
807
|
+
return _Expr<_Closure,_Value> (_Closure (__v (), __t)); \
|
808
|
+
} \
|
809
|
+
\
|
810
|
+
template<class _Dom> \
|
811
|
+
inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \
|
812
|
+
typename _Name<typename _Dom::value_type>::result_type> \
|
813
|
+
operator _Op (const typename _Dom::value_type& __t, \
|
814
|
+
const _Expr<_Dom,typename _Dom::value_type>& __v) \
|
815
|
+
{ \
|
816
|
+
typedef typename _Dom::value_type _Arg; \
|
817
|
+
typedef typename _Name<_Arg>::result_type _Value; \
|
818
|
+
typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
|
819
|
+
return _Expr<_Closure,_Value> (_Closure (__t, __v ())); \
|
820
|
+
} \
|
821
|
+
\
|
822
|
+
template<class _Dom> \
|
823
|
+
inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
|
824
|
+
typename _Name<typename _Dom::value_type>::result_type> \
|
825
|
+
operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \
|
826
|
+
const valarray<typename _Dom::value_type>& __v) \
|
827
|
+
{ \
|
828
|
+
typedef typename _Dom::value_type _Arg; \
|
829
|
+
typedef typename _Name<_Arg>::result_type _Value; \
|
830
|
+
typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Arg> _Closure; \
|
831
|
+
return _Expr<_Closure,_Value> (_Closure (__e (), __v)); \
|
832
|
+
} \
|
833
|
+
\
|
834
|
+
template<class _Dom> \
|
835
|
+
inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
|
836
|
+
typename _Name<typename _Dom::value_type>::result_type> \
|
837
|
+
operator _Op (const valarray<typename _Dom::value_type>& __v, \
|
838
|
+
const _Expr<_Dom,typename _Dom::value_type>& __e) \
|
839
|
+
{ \
|
840
|
+
typedef typename _Dom::value_type _Tp; \
|
841
|
+
typedef typename _Name<_Tp>::result_type _Value; \
|
842
|
+
typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
|
843
|
+
return _Expr<_Closure,_Value> (_Closure (__v, __e ())); \
|
844
|
+
}
|
845
|
+
|
846
|
+
_DEFINE_EXPR_BINARY_OPERATOR(+, plus)
|
847
|
+
_DEFINE_EXPR_BINARY_OPERATOR(-, minus)
|
848
|
+
_DEFINE_EXPR_BINARY_OPERATOR(*, multiplies)
|
849
|
+
_DEFINE_EXPR_BINARY_OPERATOR(/, divides)
|
850
|
+
_DEFINE_EXPR_BINARY_OPERATOR(%, modulus)
|
851
|
+
_DEFINE_EXPR_BINARY_OPERATOR(^, _Bitwise_xor)
|
852
|
+
_DEFINE_EXPR_BINARY_OPERATOR(&, _Bitwise_and)
|
853
|
+
_DEFINE_EXPR_BINARY_OPERATOR(|, _Bitwise_or)
|
854
|
+
_DEFINE_EXPR_BINARY_OPERATOR(<<, _Shift_left)
|
855
|
+
_DEFINE_EXPR_BINARY_OPERATOR(>>, _Shift_right)
|
856
|
+
|
857
|
+
#undef _DEFINE_EXPR_BINARY_OPERATOR
|
858
|
+
|
859
|
+
#define _DEFINE_EXPR_RELATIONAL_OPERATOR(_Op, _Name) \
|
860
|
+
template<class _Dom1, class _Dom2> \
|
861
|
+
inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, bool> \
|
862
|
+
operator _Op (const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
|
863
|
+
const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
|
864
|
+
{ \
|
865
|
+
typedef typename _Dom1::value_type _Arg; \
|
866
|
+
typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
|
867
|
+
return _Expr<_Closure,bool> (_Closure (__v (), __w ())); \
|
868
|
+
} \
|
869
|
+
\
|
870
|
+
template<class _Dom> \
|
871
|
+
inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \
|
872
|
+
bool> \
|
873
|
+
operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __v, \
|
874
|
+
const typename _Dom::value_type& __t) \
|
875
|
+
{ \
|
876
|
+
typedef typename _Dom::value_type _Arg; \
|
877
|
+
typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
|
878
|
+
return _Expr<_Closure,bool> (_Closure (__v (), __t)); \
|
879
|
+
} \
|
880
|
+
\
|
881
|
+
template<class _Dom> \
|
882
|
+
inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \
|
883
|
+
bool> \
|
884
|
+
operator _Op (const typename _Dom::value_type& __t, \
|
885
|
+
const _Expr<_Dom,typename _Dom::value_type>& __v) \
|
886
|
+
{ \
|
887
|
+
typedef typename _Dom::value_type _Arg; \
|
888
|
+
typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
|
889
|
+
return _Expr<_Closure,bool> (_Closure (__t, __v ())); \
|
890
|
+
} \
|
891
|
+
\
|
892
|
+
template<class _Dom> \
|
893
|
+
inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
|
894
|
+
bool> \
|
895
|
+
operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \
|
896
|
+
const valarray<typename _Dom::value_type>& __v) \
|
897
|
+
{ \
|
898
|
+
typedef typename _Dom::value_type _Tp; \
|
899
|
+
typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Tp> _Closure; \
|
900
|
+
return _Expr<_Closure,bool> (_Closure (__e (), __v)); \
|
901
|
+
} \
|
902
|
+
\
|
903
|
+
template<class _Dom> \
|
904
|
+
inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
|
905
|
+
bool> \
|
906
|
+
operator _Op (const valarray<typename _Dom::value_type>& __v, \
|
907
|
+
const _Expr<_Dom,typename _Dom::value_type>& __e) \
|
908
|
+
{ \
|
909
|
+
typedef typename _Dom::value_type _Tp; \
|
910
|
+
typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
|
911
|
+
return _Expr<_Closure,bool> (_Closure (__v, __e ())); \
|
912
|
+
}
|
913
|
+
|
914
|
+
_DEFINE_EXPR_RELATIONAL_OPERATOR(&&, logical_and)
|
915
|
+
_DEFINE_EXPR_RELATIONAL_OPERATOR(||, logical_or)
|
916
|
+
_DEFINE_EXPR_RELATIONAL_OPERATOR(==, equal_to)
|
917
|
+
_DEFINE_EXPR_RELATIONAL_OPERATOR(!=, not_equal_to)
|
918
|
+
_DEFINE_EXPR_RELATIONAL_OPERATOR(<, less)
|
919
|
+
_DEFINE_EXPR_RELATIONAL_OPERATOR(>, greater)
|
920
|
+
_DEFINE_EXPR_RELATIONAL_OPERATOR(<=, less_equal)
|
921
|
+
_DEFINE_EXPR_RELATIONAL_OPERATOR(>=, greater_equal)
|
922
|
+
|
923
|
+
#undef _DEFINE_EXPR_RELATIONAL_OPERATOR
|
924
|
+
|
925
|
+
|
926
|
+
|
927
|
+
#define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \
|
928
|
+
template<class _Dom> \
|
929
|
+
inline _Expr<_UnFunClos<_Expr,_Dom>,typename _Dom::value_type> \
|
930
|
+
_Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \
|
931
|
+
{ \
|
932
|
+
typedef typename _Dom::value_type _Tp; \
|
933
|
+
typedef _UnFunClos<_Expr,_Dom> _Closure; \
|
934
|
+
return _Expr<_Closure,_Tp>(_Closure(__e(), (_Tp(*)(_Tp))(&_Name))); \
|
935
|
+
} \
|
936
|
+
\
|
937
|
+
template<typename _Tp> \
|
938
|
+
inline _Expr<_UnFunClos<_ValArray,_Tp>,_Tp> \
|
939
|
+
_Name(const valarray<_Tp>& __v) \
|
940
|
+
{ \
|
941
|
+
typedef _UnFunClos<_ValArray,_Tp> _Closure; \
|
942
|
+
return _Expr<_Closure,_Tp> (_Closure (__v, (_Tp(*)(_Tp))(&_Name))); \
|
943
|
+
}
|
944
|
+
|
945
|
+
|
946
|
+
_DEFINE_EXPR_UNARY_FUNCTION(abs)
|
947
|
+
_DEFINE_EXPR_UNARY_FUNCTION(cos)
|
948
|
+
_DEFINE_EXPR_UNARY_FUNCTION(acos)
|
949
|
+
_DEFINE_EXPR_UNARY_FUNCTION(cosh)
|
950
|
+
_DEFINE_EXPR_UNARY_FUNCTION(sin)
|
951
|
+
_DEFINE_EXPR_UNARY_FUNCTION(asin)
|
952
|
+
_DEFINE_EXPR_UNARY_FUNCTION(sinh)
|
953
|
+
_DEFINE_EXPR_UNARY_FUNCTION(tan)
|
954
|
+
_DEFINE_EXPR_UNARY_FUNCTION(tanh)
|
955
|
+
_DEFINE_EXPR_UNARY_FUNCTION(atan)
|
956
|
+
_DEFINE_EXPR_UNARY_FUNCTION(exp)
|
957
|
+
_DEFINE_EXPR_UNARY_FUNCTION(log)
|
958
|
+
_DEFINE_EXPR_UNARY_FUNCTION(log10)
|
959
|
+
_DEFINE_EXPR_UNARY_FUNCTION(sqrt)
|
960
|
+
|
961
|
+
#undef _DEFINE_EXPR_UNARY_FUNCTION
|
962
|
+
|
963
|
+
|
964
|
+
#define _DEFINE_EXPR_BINARY_FUNCTION(_Name) \
|
965
|
+
template<class _Dom1, class _Dom2> \
|
966
|
+
inline _Expr<_BinFunClos<_Expr,_Expr,_Dom1,_Dom2>,typename _Dom1::value_type>\
|
967
|
+
_Name (const _Expr<_Dom1,typename _Dom1::value_type>& __e1, \
|
968
|
+
const _Expr<_Dom2,typename _Dom2::value_type>& __e2) \
|
969
|
+
{ \
|
970
|
+
typedef typename _Dom1::value_type _Tp; \
|
971
|
+
typedef _BinFunClos<_Expr,_Expr,_Dom1,_Dom2> _Closure; \
|
972
|
+
return _Expr<_Closure,_Tp> \
|
973
|
+
(_Closure (__e1 (), __e2 (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
|
974
|
+
} \
|
975
|
+
\
|
976
|
+
template<class _Dom> \
|
977
|
+
inline _Expr<_BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
|
978
|
+
typename _Dom::value_type> \
|
979
|
+
_Name (const _Expr<_Dom,typename _Dom::value_type>& __e, \
|
980
|
+
const valarray<typename _Dom::value_type>& __v) \
|
981
|
+
{ \
|
982
|
+
typedef typename _Dom::value_type _Tp; \
|
983
|
+
typedef _BinFunClos<_Expr,_ValArray,_Dom,_Tp> _Closure; \
|
984
|
+
return _Expr<_Closure,_Tp> \
|
985
|
+
(_Closure (__e (), __v, (_Tp(*)(_Tp, _Tp))(&_Name))); \
|
986
|
+
} \
|
987
|
+
\
|
988
|
+
template<class _Dom> \
|
989
|
+
inline _Expr<_BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
|
990
|
+
typename _Dom::value_type> \
|
991
|
+
_Name (const valarray<typename _Dom::valarray>& __v, \
|
992
|
+
const _Expr<_Dom,typename _Dom::value_type>& __e) \
|
993
|
+
{ \
|
994
|
+
typedef typename _Dom::value_type _Tp; \
|
995
|
+
typedef _BinFunClos<_ValArray,_Expr,_Tp,_Dom> _Closure; \
|
996
|
+
return _Expr<_Closure,_Tp> \
|
997
|
+
(_Closure (__v, __e (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
|
998
|
+
} \
|
999
|
+
\
|
1000
|
+
template<class _Dom> \
|
1001
|
+
inline _Expr<_BinFunClos<_Expr,_Constant,_Dom,typename _Dom::value_type>, \
|
1002
|
+
typename _Dom::value_type> \
|
1003
|
+
_Name (const _Expr<_Dom, typename _Dom::value_type>& __e, \
|
1004
|
+
const typename _Dom::value_type& __t) \
|
1005
|
+
{ \
|
1006
|
+
typedef typename _Dom::value_type _Tp; \
|
1007
|
+
typedef _BinFunClos<_Expr,_Constant,_Dom,_Tp> _Closure; \
|
1008
|
+
return _Expr<_Closure,_Tp> \
|
1009
|
+
(_Closure (__e (), __t, (_Tp(*)(_Tp, _Tp))(&_Name))); \
|
1010
|
+
} \
|
1011
|
+
\
|
1012
|
+
template<class _Dom> \
|
1013
|
+
inline _Expr<_BinFunClos<_Constant,_Expr,typename _Dom::value_type,_Dom>, \
|
1014
|
+
typename _Dom::value_type> \
|
1015
|
+
_Name (const typename _Dom::value_type& __t, \
|
1016
|
+
const _Expr<_Dom,typename _Dom::value_type>& __e) \
|
1017
|
+
{ \
|
1018
|
+
typedef typename _Dom::value_type _Tp; \
|
1019
|
+
typedef _BinFunClos<_Constant,_Expr,_Tp,_Dom> _Closure; \
|
1020
|
+
return _Expr<_Closure,_Tp> \
|
1021
|
+
(_Closure (__t, __e (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
|
1022
|
+
} \
|
1023
|
+
\
|
1024
|
+
template<typename _Tp> \
|
1025
|
+
inline _Expr<_BinFunClos<_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
|
1026
|
+
_Name (const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
|
1027
|
+
{ \
|
1028
|
+
typedef _BinFunClos<_ValArray,_ValArray,_Tp,_Tp> _Closure; \
|
1029
|
+
return _Expr<_Closure,_Tp> \
|
1030
|
+
(_Closure (__v, __w, (_Tp(*)(_Tp,_Tp))(&_Name))); \
|
1031
|
+
} \
|
1032
|
+
\
|
1033
|
+
template<typename _Tp> \
|
1034
|
+
inline _Expr<_BinFunClos<_ValArray,_Constant,_Tp,_Tp>,_Tp> \
|
1035
|
+
_Name (const valarray<_Tp>& __v, const _Tp& __t) \
|
1036
|
+
{ \
|
1037
|
+
typedef _BinFunClos<_ValArray,_Constant,_Tp,_Tp> _Closure; \
|
1038
|
+
return _Expr<_Closure,_Tp> \
|
1039
|
+
(_Closure (__v, __t, (_Tp(*)(_Tp,_Tp))(&_Name))); \
|
1040
|
+
} \
|
1041
|
+
\
|
1042
|
+
template<typename _Tp> \
|
1043
|
+
inline _Expr<_BinFunClos<_Constant,_ValArray,_Tp,_Tp>,_Tp> \
|
1044
|
+
_Name (const _Tp& __t, const valarray<_Tp>& __v) \
|
1045
|
+
{ \
|
1046
|
+
typedef _BinFunClos<_Constant,_ValArray,_Tp,_Tp> _Closure; \
|
1047
|
+
return _Expr<_Closure,_Tp> \
|
1048
|
+
(_Closure (__t, __v, (_Tp(*)(_Tp,_Tp))(&_Name))); \
|
1049
|
+
}
|
1050
|
+
|
1051
|
+
_DEFINE_EXPR_BINARY_FUNCTION(atan2)
|
1052
|
+
_DEFINE_EXPR_BINARY_FUNCTION(pow)
|
1053
|
+
|
1054
|
+
#undef _DEFINE_EXPR_BINARY_FUNCTION
|
1055
|
+
|
1056
|
+
} // std::
|
1057
|
+
|
1058
|
+
|
1059
|
+
#endif /* _CPP_VALARRAY_META_H */
|
1060
|
+
|
1061
|
+
// Local Variables:
|
1062
|
+
// mode:c++
|
1063
|
+
// End:
|