33 #ifndef _INDIRECT_ARRAY_H
34 #define _INDIRECT_ARRAY_H 1
36 #pragma GCC system_header
38 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
66 typedef _Tp value_type;
79 void operator=(
const valarray<_Tp>&)
const;
97 void operator<<=(const valarray<_Tp>&)
const;
105 void operator=(
const _Expr<_Dom, _Tp>&)
const;
107 void operator*=(
const _Expr<_Dom, _Tp>&)
const;
109 void operator/=(
const _Expr<_Dom, _Tp>&)
const;
111 void operator%=(
const _Expr<_Dom, _Tp>&)
const;
113 void operator+=(
const _Expr<_Dom, _Tp>&)
const;
115 void operator-=(
const _Expr<_Dom, _Tp>&)
const;
117 void operator^=(
const _Expr<_Dom, _Tp>&)
const;
119 void operator&=(
const _Expr<_Dom, _Tp>&)
const;
121 void operator|=(
const _Expr<_Dom, _Tp>&)
const;
123 void operator<<=(const _Expr<_Dom, _Tp>&)
const;
131 friend class valarray<_Tp>;
132 friend class gslice_array<_Tp>;
135 const _Array<size_t> _M_index;
136 const _Array<_Tp> _M_array;
142 template<
typename _Tp>
145 : _M_sz(__a._M_sz), _M_index(__a._M_index), _M_array(__a._M_array) {}
147 template<
typename _Tp>
151 : _M_sz(__s), _M_index(__i), _M_array(__a) {}
153 template<
typename _Tp>
154 inline indirect_array<_Tp>&
157 std::__valarray_copy(__a._M_array, _M_sz, __a._M_index, _M_array,
162 template<
typename _Tp>
165 { std::__valarray_fill(_M_array, _M_index, _M_sz, __t); }
167 template<
typename _Tp>
170 { std::__valarray_copy(_Array<_Tp>(__v), _M_sz, _M_array, _M_index); }
172 template<
typename _Tp>
176 { std::__valarray_copy(__e, _M_sz, _M_array, _M_index); }
178 #undef _DEFINE_VALARRAY_OPERATOR
179 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
180 template<typename _Tp> \
182 indirect_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const\
184 _Array_augmented_##_Name(_M_array, _M_index, _Array<_Tp>(__v), _M_sz); \
187 template<typename _Tp> \
188 template<class _Dom> \
190 indirect_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\
192 _Array_augmented_##_Name(_M_array, _M_index, __e, _M_sz); \
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)
206 #undef _DEFINE_VALARRAY_OPERATOR
210 _GLIBCXX_END_NAMESPACE_VERSION
void operator*=(const valarray< _Tp > &) const
Multiply slice elements by corresponding elements of v.
void operator>>=(const valarray< _Tp > &) const
Right shift slice elements by corresponding elements of v.
void operator|=(const valarray< _Tp > &) const
Logical or slice elements with corresponding elements of v.
Reference to arbitrary subset of an array.
void operator%=(const valarray< _Tp > &) const
Modulo slice elements by corresponding elements of v.
Smart array designed to support numeric processing.
void operator+=(const valarray< _Tp > &) const
Add corresponding elements of v to slice elements.
void operator^=(const valarray< _Tp > &) const
Logical xor slice elements with corresponding elements of v.
void operator&=(const valarray< _Tp > &) const
Logical and slice elements with corresponding elements of v.
indirect_array(const indirect_array &)
Copy constructor. Both slices refer to the same underlying array.
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
Divide slice elements by corresponding elements of v.