libstdc++: indirect_array.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#ifndef _INDIRECT_ARRAY_H
33#define _INDIRECT_ARRAY_H 1
34
35#pragma GCC system_header
36
37namespace std _GLIBCXX_VISIBILITY(default)
38{
39_GLIBCXX_BEGIN_NAMESPACE_VERSION
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 template <class _Tp>
63 {
64 public:
65 typedef _Tp value_type;
66
67
68
69
70
72
73
74
76
77
79
81
83
85
87
89
91
93
95
97
99
100 void operator= (const _Tp&) const;
101
102
103 template<class _Dom>
104 void operator=(const _Expr<_Dom, _Tp>&) const;
105 template<class _Dom>
106 void operator*=(const _Expr<_Dom, _Tp>&) const;
107 template<class _Dom>
108 void operator/=(const _Expr<_Dom, _Tp>&) const;
109 template<class _Dom>
110 void operator%=(const _Expr<_Dom, _Tp>&) const;
111 template<class _Dom>
112 void operator+=(const _Expr<_Dom, _Tp>&) const;
113 template<class _Dom>
114 void operator-=(const _Expr<_Dom, _Tp>&) const;
115 template<class _Dom>
116 void operator^=(const _Expr<_Dom, _Tp>&) const;
117 template<class _Dom>
118 void operator&=(const _Expr<_Dom, _Tp>&) const;
119 template<class _Dom>
120 void operator|=(const _Expr<_Dom, _Tp>&) const;
121 template<class _Dom>
122 void operator<<=(const _Expr<_Dom, _Tp>&) const;
123 template<class _Dom>
124 void operator>>=(const _Expr<_Dom, _Tp>&) const;
125
126 private:
127
129
132
133 const size_t _M_sz;
134 const _Array<size_t> _M_index;
135 const _Array<_Tp> _M_array;
136
137
139 };
140
141 template<typename _Tp>
142 inline
144 : _M_sz(__a._M_sz), _M_index(__a._M_index), _M_array(__a._M_array) {}
145
146 template<typename _Tp>
147 inline
148 indirect_array<_Tp>::indirect_array(_Array<_Tp> __a, size_t __s,
149 _Array<size_t> __i)
150 : _M_sz(__s), _M_index(__i), _M_array(__a) {}
151
152 template<typename _Tp>
153 inline indirect_array<_Tp>&
155 {
156 std::__valarray_copy(__a._M_array, _M_sz, __a._M_index, _M_array,
157 _M_index);
158 return *this;
159 }
160
161 template<typename _Tp>
162 inline void
164 { std::__valarray_fill(_M_array, _M_index, _M_sz, __t); }
165
166 template<typename _Tp>
167 inline void
169 { std::__valarray_copy(_Array<_Tp>(__v), _M_sz, _M_array, _M_index); }
170
171 template<typename _Tp>
172 template<class _Dom>
173 inline void
175 { std::__valarray_copy(__e, _M_sz, _M_array, _M_index); }
176
177
178#undef _DEFINE_VALARRAY_OPERATOR
179#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
180 template<typename _Tp> \
181 inline void \
182 indirect_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const\
183 { \
184 _Array_augmented_##_Name(_M_array, _M_index, _Array<_Tp>(__v), _M_sz); \
185 } \
186 \
187 template<typename _Tp> \
188 template<class _Dom> \
189 inline void \
190 indirect_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\
191 { \
192 _Array_augmented_##_Name(_M_array, _M_index, __e, _M_sz); \
193 }
194
195_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
196_DEFINE_VALARRAY_OPERATOR(/, __divides)
197_DEFINE_VALARRAY_OPERATOR(%, __modulus)
198_DEFINE_VALARRAY_OPERATOR(+, __plus)
199_DEFINE_VALARRAY_OPERATOR(-, __minus)
200_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
201_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
202_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
203_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
204_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
205
206#undef _DEFINE_VALARRAY_OPERATOR
207
208
209
210
211_GLIBCXX_END_NAMESPACE_VERSION
212}
213
214#endif
ISO C++ entities toplevel namespace is std.
Smart array designed to support numeric processing.
Reference to multi-dimensional subset of an array.
Reference to arbitrary subset of an array.
void operator/=(const valarray< _Tp > &) const
Divide slice elements by corresponding elements of v.
void operator^=(const valarray< _Tp > &) const
Logical xor slice elements with corresponding elements of v.
void operator|=(const valarray< _Tp > &) const
Logical or slice elements with corresponding elements of v.
void operator<<=(const valarray< _Tp > &) const
Left shift slice elements by corresponding elements of v.
void operator>>=(const valarray< _Tp > &) const
Right shift slice elements by corresponding elements of v.
indirect_array & operator=(const indirect_array &)
Assignment operator. Assigns elements to corresponding elements of a.
void operator-=(const valarray< _Tp > &) const
Subtract corresponding elements of v from slice elements.
void operator*=(const valarray< _Tp > &) const
Multiply slice elements by corresponding elements of v.
indirect_array(const indirect_array &)
Copy constructor. Both slices refer to the same underlying array.
void operator&=(const valarray< _Tp > &) const
Logical and slice elements with corresponding elements of v.
void operator+=(const valarray< _Tp > &) const
Add corresponding elements of v to slice elements.
void operator%=(const valarray< _Tp > &) const
Modulo slice elements by corresponding elements of v.