32 #ifndef _SLICE_ARRAY_H
33 #define _SLICE_ARRAY_H 1
35 #pragma GCC system_header
37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
72 slice(
size_t __o,
size_t __d,
size_t __s);
91 : _M_off(0), _M_sz(0), _M_st(0) {}
95 : _M_off(__o), _M_sz(__d), _M_st(__s) {}
122 template<
typename _Tp>
126 typedef _Tp value_type;
139 void operator=(
const valarray<_Tp>&)
const;
157 void operator<<=(const valarray<_Tp>&)
const;
165 void operator=(
const _Expr<_Dom, _Tp>&)
const;
167 void operator*=(
const _Expr<_Dom, _Tp>&)
const;
169 void operator/=(
const _Expr<_Dom, _Tp>&)
const;
171 void operator%=(
const _Expr<_Dom, _Tp>&)
const;
173 void operator+=(
const _Expr<_Dom, _Tp>&)
const;
175 void operator-=(
const _Expr<_Dom, _Tp>&)
const;
177 void operator^=(
const _Expr<_Dom, _Tp>&)
const;
179 void operator&=(
const _Expr<_Dom, _Tp>&)
const;
181 void operator|=(
const _Expr<_Dom, _Tp>&)
const;
183 void operator<<=(const _Expr<_Dom, _Tp>&)
const;
188 friend class valarray<_Tp>;
192 const size_t _M_stride;
193 const _Array<_Tp> _M_array;
199 template<
typename _Tp>
202 : _M_sz(__s.size()), _M_stride(__s.stride()),
203 _M_array(__a.
begin() + __s.start()) {}
205 template<
typename _Tp>
208 : _M_sz(a._M_sz), _M_stride(a._M_stride), _M_array(a._M_array) {}
213 template<
typename _Tp>
217 std::__valarray_copy(__a._M_array, __a._M_sz, __a._M_stride,
218 _M_array, _M_stride);
222 template<
typename _Tp>
225 { std::__valarray_fill(_M_array, _M_sz, _M_stride, __t); }
227 template<
typename _Tp>
230 { std::__valarray_copy(_Array<_Tp>(__v), _M_array, _M_sz, _M_stride); }
232 template<
typename _Tp>
236 { std::__valarray_copy(__e, _M_sz, _M_array, _M_stride); }
238 #undef _DEFINE_VALARRAY_OPERATOR
239 #define _DEFINE_VALARRAY_OPERATOR(_Op,_Name) \
240 template<typename _Tp> \
242 slice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
244 _Array_augmented_##_Name(_M_array, _M_sz, _M_stride, _Array<_Tp>(__v));\
247 template<typename _Tp> \
248 template<class _Dom> \
250 slice_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\
252 _Array_augmented_##_Name(_M_array, _M_stride, __e, _M_sz); \
256 _DEFINE_VALARRAY_OPERATOR(*, __multiplies)
257 _DEFINE_VALARRAY_OPERATOR(/, __divides)
258 _DEFINE_VALARRAY_OPERATOR(%, __modulus)
259 _DEFINE_VALARRAY_OPERATOR(+, __plus)
260 _DEFINE_VALARRAY_OPERATOR(-, __minus)
261 _DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
262 _DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
263 _DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
264 _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
265 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
267 #undef _DEFINE_VALARRAY_OPERATOR
271 _GLIBCXX_END_NAMESPACE_VERSION
size_t start() const
Return array offset of first slice element.
void operator-=(const valarray< _Tp > &) const
Subtract corresponding elements of v from slice elements.
Reference to one-dimensional subset of an array.
void operator>>=(const valarray< _Tp > &) const
Right shift slice elements by corresponding elements of v.
void operator%=(const valarray< _Tp > &) const
Modulo slice elements by corresponding elements of v.
size_t stride() const
Return array stride of slice.
void operator&=(const valarray< _Tp > &) const
Logical and slice elements with corresponding elements of v.
slice()
Construct an empty slice.
void operator/=(const valarray< _Tp > &) const
Divide slice elements by corresponding elements of v.
void operator|=(const valarray< _Tp > &) const
Logical or slice elements with corresponding elements of v.
ISO C++ entities toplevel namespace is std.
slice_array & operator=(const slice_array &)
Assignment operator. Assigns slice elements to corresponding elements of a.
void operator^=(const valarray< _Tp > &) const
Logical xor slice elements with corresponding elements of v.
void operator+=(const valarray< _Tp > &) const
Add corresponding elements of v to slice elements.
auto begin(_Container &__cont) -> decltype(__cont.begin())
Return an iterator pointing to the first element of the container.
size_t size() const
Return size of slice.
void operator*=(const valarray< _Tp > &) const
Multiply slice elements by corresponding elements of v.
Class defining one-dimensional subset of an array.