34 #define _MASK_ARRAY_H 1
36 #pragma GCC system_header
38 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
66 typedef _Tp value_type;
78 void operator=(
const valarray<_Tp>&)
const;
96 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;
128 mask_array(_Array<_Tp>,
size_t, _Array<bool>);
129 friend class valarray<_Tp>;
132 const _Array<bool> _M_mask;
133 const _Array<_Tp> _M_array;
139 template<
typename _Tp>
141 : _M_sz(a._M_sz), _M_mask(a._M_mask), _M_array(a._M_array) {}
143 template<
typename _Tp>
146 : _M_sz(__s), _M_mask(__m), _M_array(__a) {}
148 template<
typename _Tp>
149 inline mask_array<_Tp>&
152 std::__valarray_copy(__a._M_array, __a._M_mask,
153 _M_sz, _M_array, _M_mask);
157 template<
typename _Tp>
160 { std::__valarray_fill(_M_array, _M_sz, _M_mask, __t); }
162 template<
typename _Tp>
165 { std::__valarray_copy(_Array<_Tp>(__v), __v.
size(), _M_array, _M_mask); }
167 template<
typename _Tp>
171 { std::__valarray_copy(__e, __e.size(), _M_array, _M_mask); }
173 #undef _DEFINE_VALARRAY_OPERATOR
174 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
175 template<typename _Tp> \
177 mask_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
179 _Array_augmented_##_Name(_M_array, _M_mask, \
180 _Array<_Tp>(__v), __v.size()); \
183 template<typename _Tp> \
184 template<class _Dom> \
186 mask_array<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) const\
188 _Array_augmented_##_Name(_M_array, _M_mask, __e, __e.size()); \
191 _DEFINE_VALARRAY_OPERATOR(*, __multiplies)
192 _DEFINE_VALARRAY_OPERATOR(/, __divides)
193 _DEFINE_VALARRAY_OPERATOR(%, __modulus)
194 _DEFINE_VALARRAY_OPERATOR(+, __plus)
195 _DEFINE_VALARRAY_OPERATOR(-, __minus)
196 _DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
197 _DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
198 _DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
199 _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
200 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
202 #undef _DEFINE_VALARRAY_OPERATOR
206 _GLIBCXX_END_NAMESPACE_VERSION
Reference to selected subset of an array.
Smart array designed to support numeric processing.
mask_array(const mask_array &)
Copy constructor. Both slices refer to the same underlying array.
void operator^=(const valarray< _Tp > &) const
Logical xor slice elements with corresponding elements of v.
mask_array & operator=(const mask_array &)
Assignment operator. Assigns elements to corresponding elements of a.
void operator|=(const valarray< _Tp > &) const
Logical or 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
Logical and slice elements with corresponding elements of v.
size_t size() const
Return the number of elements in array.
void operator>>=(const valarray< _Tp > &) const
Right shift slice elements by corresponding elements of v.
void operator/=(const valarray< _Tp > &) const
Divide slice elements by corresponding elements of v.
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.
void operator%=(const valarray< _Tp > &) const
Modulo slice elements by corresponding elements of v.