2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_VALARRAY
11 #define _LIBCPP_VALARRAY
27 explicit valarray(size_t n);
28 valarray(const value_type& x, size_t n);
29 valarray(const value_type* px, size_t n);
30 valarray(const valarray& v);
31 valarray(valarray&& v) noexcept;
32 valarray(const slice_array<value_type>& sa);
33 valarray(const gslice_array<value_type>& ga);
34 valarray(const mask_array<value_type>& ma);
35 valarray(const indirect_array<value_type>& ia);
36 valarray(initializer_list<value_type> il);
40 valarray& operator=(const valarray& v);
41 valarray& operator=(valarray&& v) noexcept;
42 valarray& operator=(initializer_list<value_type> il);
43 valarray& operator=(const value_type& x);
44 valarray& operator=(const slice_array<value_type>& sa);
45 valarray& operator=(const gslice_array<value_type>& ga);
46 valarray& operator=(const mask_array<value_type>& ma);
47 valarray& operator=(const indirect_array<value_type>& ia);
50 const value_type& operator[](size_t i) const;
51 value_type& operator[](size_t i);
54 valarray operator[](slice s) const;
55 slice_array<value_type> operator[](slice s);
56 valarray operator[](const gslice& gs) const;
57 gslice_array<value_type> operator[](const gslice& gs);
58 valarray operator[](const valarray<bool>& vb) const;
59 mask_array<value_type> operator[](const valarray<bool>& vb);
60 valarray operator[](const valarray<size_t>& vs) const;
61 indirect_array<value_type> operator[](const valarray<size_t>& vs);
64 valarray operator+() const;
65 valarray operator-() const;
66 valarray operator~() const;
67 valarray<bool> operator!() const;
69 // computed assignment:
70 valarray& operator*= (const value_type& x);
71 valarray& operator/= (const value_type& x);
72 valarray& operator%= (const value_type& x);
73 valarray& operator+= (const value_type& x);
74 valarray& operator-= (const value_type& x);
75 valarray& operator^= (const value_type& x);
76 valarray& operator&= (const value_type& x);
77 valarray& operator|= (const value_type& x);
78 valarray& operator<<=(const value_type& x);
79 valarray& operator>>=(const value_type& x);
81 valarray& operator*= (const valarray& v);
82 valarray& operator/= (const valarray& v);
83 valarray& operator%= (const valarray& v);
84 valarray& operator+= (const valarray& v);
85 valarray& operator-= (const valarray& v);
86 valarray& operator^= (const valarray& v);
87 valarray& operator|= (const valarray& v);
88 valarray& operator&= (const valarray& v);
89 valarray& operator<<=(const valarray& v);
90 valarray& operator>>=(const valarray& v);
93 void swap(valarray& v) noexcept;
97 value_type sum() const;
98 value_type min() const;
99 value_type max() const;
101 valarray shift (int i) const;
102 valarray cshift(int i) const;
103 valarray apply(value_type f(value_type)) const;
104 valarray apply(value_type f(const value_type&)) const;
105 void resize(size_t n, value_type x = value_type());
108 template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>;
114 slice(size_t start, size_t size, size_t stride);
116 size_t start() const;
118 size_t stride() const;
120 friend bool operator==(const slice& x, const slice& y); // since C++20
127 typedef T value_type;
129 const slice_array& operator=(const slice_array& sa) const;
130 void operator= (const valarray<value_type>& v) const;
131 void operator*= (const valarray<value_type>& v) const;
132 void operator/= (const valarray<value_type>& v) const;
133 void operator%= (const valarray<value_type>& v) const;
134 void operator+= (const valarray<value_type>& v) const;
135 void operator-= (const valarray<value_type>& v) const;
136 void operator^= (const valarray<value_type>& v) const;
137 void operator&= (const valarray<value_type>& v) const;
138 void operator|= (const valarray<value_type>& v) const;
139 void operator<<=(const valarray<value_type>& v) const;
140 void operator>>=(const valarray<value_type>& v) const;
142 void operator=(const value_type& x) const;
143 void operator=(const valarray<T>& val_arr) const;
145 slice_array() = delete;
152 gslice(size_t start, const valarray<size_t>& size,
153 const valarray<size_t>& stride);
155 size_t start() const;
156 valarray<size_t> size() const;
157 valarray<size_t> stride() const;
164 typedef T value_type;
166 void operator= (const valarray<value_type>& v) const;
167 void operator*= (const valarray<value_type>& v) const;
168 void operator/= (const valarray<value_type>& v) const;
169 void operator%= (const valarray<value_type>& v) const;
170 void operator+= (const valarray<value_type>& v) const;
171 void operator-= (const valarray<value_type>& v) const;
172 void operator^= (const valarray<value_type>& v) const;
173 void operator&= (const valarray<value_type>& v) const;
174 void operator|= (const valarray<value_type>& v) const;
175 void operator<<=(const valarray<value_type>& v) const;
176 void operator>>=(const valarray<value_type>& v) const;
178 gslice_array(const gslice_array& ga);
180 const gslice_array& operator=(const gslice_array& ga) const;
181 void operator=(const value_type& x) const;
183 gslice_array() = delete;
190 typedef T value_type;
192 void operator= (const valarray<value_type>& v) const;
193 void operator*= (const valarray<value_type>& v) const;
194 void operator/= (const valarray<value_type>& v) const;
195 void operator%= (const valarray<value_type>& v) const;
196 void operator+= (const valarray<value_type>& v) const;
197 void operator-= (const valarray<value_type>& v) const;
198 void operator^= (const valarray<value_type>& v) const;
199 void operator&= (const valarray<value_type>& v) const;
200 void operator|= (const valarray<value_type>& v) const;
201 void operator<<=(const valarray<value_type>& v) const;
202 void operator>>=(const valarray<value_type>& v) const;
204 mask_array(const mask_array& ma);
206 const mask_array& operator=(const mask_array& ma) const;
207 void operator=(const value_type& x) const;
209 mask_array() = delete;
216 typedef T value_type;
218 void operator= (const valarray<value_type>& v) const;
219 void operator*= (const valarray<value_type>& v) const;
220 void operator/= (const valarray<value_type>& v) const;
221 void operator%= (const valarray<value_type>& v) const;
222 void operator+= (const valarray<value_type>& v) const;
223 void operator-= (const valarray<value_type>& v) const;
224 void operator^= (const valarray<value_type>& v) const;
225 void operator&= (const valarray<value_type>& v) const;
226 void operator|= (const valarray<value_type>& v) const;
227 void operator<<=(const valarray<value_type>& v) const;
228 void operator>>=(const valarray<value_type>& v) const;
230 indirect_array(const indirect_array& ia);
232 const indirect_array& operator=(const indirect_array& ia) const;
233 void operator=(const value_type& x) const;
235 indirect_array() = delete;
238 template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
240 template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
241 template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
242 template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
244 template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
245 template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
246 template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
248 template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
249 template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
250 template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
252 template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
253 template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
254 template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
256 template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
257 template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
258 template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
260 template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
261 template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
262 template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
264 template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
265 template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
266 template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
268 template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
269 template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
270 template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
272 template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
273 template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
274 template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
276 template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
277 template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
278 template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
280 template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
281 template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
282 template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
284 template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
285 template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
286 template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
288 template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
289 template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
290 template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
292 template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
293 template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
294 template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
296 template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
297 template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
298 template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
300 template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
301 template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
302 template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
304 template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
305 template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
306 template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
308 template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
309 template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
310 template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
312 template<class T> valarray<T> abs (const valarray<T>& x);
313 template<class T> valarray<T> acos (const valarray<T>& x);
314 template<class T> valarray<T> asin (const valarray<T>& x);
315 template<class T> valarray<T> atan (const valarray<T>& x);
317 template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
318 template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
319 template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
321 template<class T> valarray<T> cos (const valarray<T>& x);
322 template<class T> valarray<T> cosh (const valarray<T>& x);
323 template<class T> valarray<T> exp (const valarray<T>& x);
324 template<class T> valarray<T> log (const valarray<T>& x);
325 template<class T> valarray<T> log10(const valarray<T>& x);
327 template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
328 template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
329 template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
331 template<class T> valarray<T> sin (const valarray<T>& x);
332 template<class T> valarray<T> sinh (const valarray<T>& x);
333 template<class T> valarray<T> sqrt (const valarray<T>& x);
334 template<class T> valarray<T> tan (const valarray<T>& x);
335 template<class T> valarray<T> tanh (const valarray<T>& x);
337 template <class T> unspecified1 begin(valarray<T>& v);
338 template <class T> unspecified2 begin(const valarray<T>& v);
339 template <class T> unspecified1 end(valarray<T>& v);
340 template <class T> unspecified2 end(const valarray<T>& v);
346 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
347 # include <__cxx03/valarray>
349 # include <__algorithm/copy.h>
350 # include <__algorithm/count.h>
351 # include <__algorithm/fill.h>
352 # include <__algorithm/max_element.h>
353 # include <__algorithm/min.h>
354 # include <__algorithm/min_element.h>
355 # include <__algorithm/unwrap_iter.h>
358 # include <__cstddef/ptrdiff_t.h>
359 # include <__functional/operations.h>
360 # include <__memory/addressof.h>
361 # include <__memory/allocator.h>
362 # include <__memory/uninitialized_algorithms.h>
363 # include <__type_traits/decay.h>
364 # include <__type_traits/remove_reference.h>
365 # include <__utility/move.h>
366 # include <__utility/swap.h>
370 // standard-mandated includes
373 # include <initializer_list>
375 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
376 # pragma GCC system_header
380 # include <__undef_macros>
382 _LIBCPP_BEGIN_NAMESPACE_STD
385 class _LIBCPP_TEMPLATE_VIS valarray;
387 class _LIBCPP_TEMPLATE_VIS slice {
393 _LIBCPP_HIDE_FROM_ABI slice() : __start_(0), __size_(0), __stride_(0) {}
395 _LIBCPP_HIDE_FROM_ABI slice(size_t __start, size_t __size, size_t __stride)
396 : __start_(__start), __size_(__size), __stride_(__stride) {}
398 _LIBCPP_HIDE_FROM_ABI size_t start() const { return __start_; }
399 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
400 _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; }
402 # if _LIBCPP_STD_VER >= 20
404 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) {
405 return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride();
412 class _LIBCPP_TEMPLATE_VIS slice_array;
413 class _LIBCPP_EXPORTED_FROM_ABI gslice;
415 class _LIBCPP_TEMPLATE_VIS gslice_array;
417 class _LIBCPP_TEMPLATE_VIS mask_array;
419 class _LIBCPP_TEMPLATE_VIS indirect_array;
422 _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v);
425 _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v);
428 _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v);
431 _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v);
433 template <class _Op, class _A0>
435 typedef typename _Op::__result_type __result_type;
436 using value_type = __decay_t<__result_type>;
441 _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
443 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); }
445 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
448 template <class _Op, class _A0, class _A1>
450 typedef typename _Op::__result_type __result_type;
451 using value_type = __decay_t<__result_type>;
457 _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
458 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
460 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }
462 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
466 class __scalar_expr {
468 typedef _Tp value_type;
469 typedef const _Tp& __result_type;
472 const value_type& __t_;
476 _LIBCPP_HIDE_FROM_ABI explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
478 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t) const { return __t_; }
480 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __s_; }
484 struct __unary_plus {
485 typedef _Tp __result_type;
486 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return +__x; }
491 typedef _Tp __result_type;
492 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }
496 struct __bit_shift_left {
497 typedef _Tp __result_type;
498 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x << __y; }
502 struct __bit_shift_right {
503 typedef _Tp __result_type;
504 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x >> __y; }
507 template <class _Tp, class _Fp>
508 struct __apply_expr {
513 typedef _Tp __result_type;
515 _LIBCPP_HIDE_FROM_ABI explicit __apply_expr(_Fp __f) : __f_(__f) {}
517 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return __f_(__x); }
522 typedef _Tp __result_type;
523 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::abs(__x); }
528 typedef _Tp __result_type;
529 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::acos(__x); }
534 typedef _Tp __result_type;
535 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::asin(__x); }
540 typedef _Tp __result_type;
541 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::atan(__x); }
545 struct __atan2_expr {
546 typedef _Tp __result_type;
547 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::atan2(__x, __y); }
552 typedef _Tp __result_type;
553 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cos(__x); }
558 typedef _Tp __result_type;
559 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cosh(__x); }
564 typedef _Tp __result_type;
565 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::exp(__x); }
570 typedef _Tp __result_type;
571 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log(__x); }
575 struct __log10_expr {
576 typedef _Tp __result_type;
577 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log10(__x); }
582 typedef _Tp __result_type;
583 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::pow(__x, __y); }
588 typedef _Tp __result_type;
589 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sin(__x); }
594 typedef _Tp __result_type;
595 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sinh(__x); }
600 typedef _Tp __result_type;
601 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sqrt(__x); }
606 typedef _Tp __result_type;
607 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tan(__x); }
612 typedef _Tp __result_type;
613 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tanh(__x); }
616 template <class _ValExpr>
618 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
621 typedef typename _RmExpr::value_type value_type;
622 typedef value_type __result_type;
630 _LIBCPP_HIDE_FROM_ABI __slice_expr(const slice& __sl, const _RmExpr& __e)
631 : __expr_(__e), __start_(__sl.start()), __size_(__sl.size()), __stride_(__sl.stride()) {}
634 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__start_ + __i * __stride_]; }
636 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
639 friend class __val_expr;
641 friend class _LIBCPP_TEMPLATE_VIS valarray;
644 template <class _ValExpr>
647 template <class _ValExpr>
648 class __indirect_expr;
650 template <class _ValExpr>
652 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
655 typedef typename _RmExpr::value_type value_type;
656 typedef value_type __result_type;
664 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
666 _LIBCPP_HIDE_FROM_ABI __shift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()), __n_(__n) {
667 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
668 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
669 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
673 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __j) const {
674 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
675 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
676 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
679 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
682 friend class __val_expr;
685 template <class _ValExpr>
686 class __cshift_expr {
687 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
690 typedef typename _RmExpr::value_type value_type;
691 typedef value_type __result_type;
700 _LIBCPP_HIDE_FROM_ABI __cshift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()) {
701 __n %= static_cast<int>(__size_);
703 __m_ = __size_ - __n;
705 __o2_ = __n - __size_;
708 __o1_ = __n + __size_;
714 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const {
716 return __expr_[__i + __o1_];
717 return __expr_[__i + __o2_];
720 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
723 friend class __val_expr;
726 template <class _ValExpr>
729 template <class _ValExpr>
730 struct __is_val_expr : false_type {};
732 template <class _ValExpr>
733 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
736 struct __is_val_expr<valarray<_Tp> > : true_type {};
739 struct __is_val_expr<slice_array<_Tp> > : true_type {};
742 struct __is_val_expr<gslice_array<_Tp> > : true_type {};
745 struct __is_val_expr<mask_array<_Tp> > : true_type {};
748 struct __is_val_expr<indirect_array<_Tp> > : true_type {};
750 // The functions using a __val_expr access the elements by their index.
751 // valarray and the libc++ lazy proxies have an operator[]. The
752 // Standard proxy array's don't have this operator, instead they have a
753 // implementation specific accessor
756 // The functions use the non-member function
757 // __get(__val_expr, size_t)
759 // If the __val_expr is a specialization of __val_expr_use_member_functions it
760 // uses the __val_expr's member function
762 // else it uses the __val_expr's member function
763 // operator[](size_t)
764 template <class _ValExpr>
765 struct __val_expr_use_member_functions;
768 struct __val_expr_use_member_functions : false_type {};
771 struct __val_expr_use_member_functions<slice_array<_Tp> > : true_type {};
774 struct __val_expr_use_member_functions<gslice_array<_Tp> > : true_type {};
777 struct __val_expr_use_member_functions<mask_array<_Tp> > : true_type {};
780 struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {};
783 class _LIBCPP_TEMPLATE_VIS valarray {
785 typedef _Tp value_type;
786 typedef _Tp __result_type;
789 value_type* __begin_;
793 // construct/destroy:
794 _LIBCPP_HIDE_FROM_ABI valarray() : __begin_(nullptr), __end_(nullptr) {}
795 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit valarray(size_t __n);
796 _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n);
797 valarray(const value_type* __p, size_t __n);
798 valarray(const valarray& __v);
799 # ifndef _LIBCPP_CXX03_LANG
800 _LIBCPP_HIDE_FROM_ABI valarray(valarray&& __v) _NOEXCEPT;
801 valarray(initializer_list<value_type> __il);
802 # endif // _LIBCPP_CXX03_LANG
803 valarray(const slice_array<value_type>& __sa);
804 valarray(const gslice_array<value_type>& __ga);
805 valarray(const mask_array<value_type>& __ma);
806 valarray(const indirect_array<value_type>& __ia);
807 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 ~valarray();
810 valarray& operator=(const valarray& __v);
811 # ifndef _LIBCPP_CXX03_LANG
812 _LIBCPP_HIDE_FROM_ABI valarray& operator=(valarray&& __v) _NOEXCEPT;
813 _LIBCPP_HIDE_FROM_ABI valarray& operator=(initializer_list<value_type>);
814 # endif // _LIBCPP_CXX03_LANG
815 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x);
816 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa);
817 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga);
818 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const mask_array<value_type>& __ma);
819 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const indirect_array<value_type>& __ia);
820 template <class _ValExpr>
821 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v);
824 _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const {
825 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds");
826 return __begin_[__i];
829 _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) {
830 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds");
831 return __begin_[__i];
834 // subset operations:
835 _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
836 _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s);
837 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
838 _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs);
839 # ifndef _LIBCPP_CXX03_LANG
840 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
841 _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs);
842 # endif // _LIBCPP_CXX03_LANG
843 _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
844 _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb);
845 # ifndef _LIBCPP_CXX03_LANG
846 _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
847 _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb);
848 # endif // _LIBCPP_CXX03_LANG
849 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
850 _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs);
851 # ifndef _LIBCPP_CXX03_LANG
852 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
853 _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs);
854 # endif // _LIBCPP_CXX03_LANG
857 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;
858 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const;
859 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const;
860 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const;
862 // computed assignment:
863 _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const value_type& __x);
864 _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const value_type& __x);
865 _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const value_type& __x);
866 _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const value_type& __x);
867 _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const value_type& __x);
868 _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const value_type& __x);
869 _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const value_type& __x);
870 _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const value_type& __x);
871 _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const value_type& __x);
872 _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const value_type& __x);
874 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
875 _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const _Expr& __v);
877 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
878 _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const _Expr& __v);
880 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
881 _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const _Expr& __v);
883 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
884 _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const _Expr& __v);
886 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
887 _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const _Expr& __v);
889 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
890 _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const _Expr& __v);
892 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
893 _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const _Expr& __v);
895 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
896 _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const _Expr& __v);
898 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
899 _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const _Expr& __v);
901 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
902 _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const _Expr& __v);
905 _LIBCPP_HIDE_FROM_ABI void swap(valarray& __v) _NOEXCEPT;
907 _LIBCPP_HIDE_FROM_ABI size_t size() const { return static_cast<size_t>(__end_ - __begin_); }
909 _LIBCPP_HIDE_FROM_ABI value_type sum() const;
910 _LIBCPP_HIDE_FROM_ABI value_type min() const;
911 _LIBCPP_HIDE_FROM_ABI value_type max() const;
913 valarray shift(int __i) const;
914 valarray cshift(int __i) const;
915 valarray apply(value_type __f(value_type)) const;
916 valarray apply(value_type __f(const value_type&)) const;
917 void resize(size_t __n, value_type __x = value_type());
921 friend class _LIBCPP_TEMPLATE_VIS valarray;
923 friend class _LIBCPP_TEMPLATE_VIS slice_array;
925 friend class _LIBCPP_TEMPLATE_VIS gslice_array;
927 friend class _LIBCPP_TEMPLATE_VIS mask_array;
929 friend class __mask_expr;
931 friend class _LIBCPP_TEMPLATE_VIS indirect_array;
933 friend class __indirect_expr;
935 friend class __val_expr;
938 friend _Up* begin(valarray<_Up>& __v);
941 friend const _Up* begin(const valarray<_Up>& __v);
944 friend _Up* end(valarray<_Up>& __v);
947 friend const _Up* end(const valarray<_Up>& __v);
949 _LIBCPP_HIDE_FROM_ABI void __clear(size_t __capacity);
950 valarray& __assign_range(const value_type* __f, const value_type* __l);
953 # if _LIBCPP_STD_VER >= 17
954 template <class _Tp, size_t _Size>
955 valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>;
958 template <class _Expr,
959 __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0>
960 _LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {
961 return __v.__get(__i);
964 template <class _Expr,
965 __enable_if_t<__is_val_expr<_Expr>::value && !__val_expr_use_member_functions<_Expr>::value, int> = 0>
966 _LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {
970 extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t);
972 template <class _Op, class _Tp>
973 struct _UnaryOp<_Op, valarray<_Tp> > {
974 typedef typename _Op::__result_type __result_type;
975 using value_type = __decay_t<__result_type>;
978 const valarray<_Tp>& __a0_;
980 _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
982 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); }
984 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
987 template <class _Op, class _Tp, class _A1>
988 struct _BinaryOp<_Op, valarray<_Tp>, _A1> {
989 typedef typename _Op::__result_type __result_type;
990 using value_type = __decay_t<__result_type>;
993 const valarray<_Tp>& __a0_;
996 _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
997 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
999 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }
1001 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
1004 template <class _Op, class _A0, class _Tp>
1005 struct _BinaryOp<_Op, _A0, valarray<_Tp> > {
1006 typedef typename _Op::__result_type __result_type;
1007 using value_type = __decay_t<__result_type>;
1011 const valarray<_Tp>& __a1_;
1013 _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1014 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1016 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }
1018 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
1021 template <class _Op, class _Tp>
1022 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > {
1023 typedef typename _Op::__result_type __result_type;
1024 using value_type = __decay_t<__result_type>;
1027 const valarray<_Tp>& __a0_;
1028 const valarray<_Tp>& __a1_;
1030 _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1031 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1033 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }
1035 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
1040 template <class _Tp>
1041 class _LIBCPP_TEMPLATE_VIS slice_array {
1043 typedef _Tp value_type;
1051 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1052 void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;
1054 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1055 void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;
1057 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1058 void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;
1060 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1061 void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;
1063 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1064 void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;
1066 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1067 void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;
1069 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1070 void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;
1072 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1073 void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;
1075 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1076 void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;
1078 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1079 void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;
1081 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1082 void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;
1084 slice_array(slice_array const&) = default;
1086 _LIBCPP_HIDE_FROM_ABI const slice_array& operator=(const slice_array& __sa) const;
1088 _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
1090 _LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const;
1092 // Behaves like __val_expr::operator[], which returns by value.
1093 _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1094 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "slice_array.__get() index out of bounds");
1095 return __vp_[__i * __stride_];
1099 _LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v)
1100 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {}
1103 friend class valarray;
1106 template <class _Tp>
1107 inline const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const {
1108 value_type* __t = __vp_;
1109 const value_type* __s = __sa.__vp_;
1110 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1115 template <class _Tp>
1116 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1117 inline void slice_array<_Tp>::operator=(const _Expr& __v) const {
1118 value_type* __t = __vp_;
1119 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1123 template <class _Tp>
1124 inline void slice_array<_Tp>::operator=(const valarray<value_type>& __va) const {
1125 value_type* __t = __vp_;
1126 for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)
1130 template <class _Tp>
1131 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1132 inline void slice_array<_Tp>::operator*=(const _Expr& __v) const {
1133 value_type* __t = __vp_;
1134 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1138 template <class _Tp>
1139 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1140 inline void slice_array<_Tp>::operator/=(const _Expr& __v) const {
1141 value_type* __t = __vp_;
1142 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1146 template <class _Tp>
1147 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1148 inline void slice_array<_Tp>::operator%=(const _Expr& __v) const {
1149 value_type* __t = __vp_;
1150 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1154 template <class _Tp>
1155 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1156 inline void slice_array<_Tp>::operator+=(const _Expr& __v) const {
1157 value_type* __t = __vp_;
1158 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1162 template <class _Tp>
1163 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1164 inline void slice_array<_Tp>::operator-=(const _Expr& __v) const {
1165 value_type* __t = __vp_;
1166 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1170 template <class _Tp>
1171 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1172 inline void slice_array<_Tp>::operator^=(const _Expr& __v) const {
1173 value_type* __t = __vp_;
1174 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1178 template <class _Tp>
1179 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1180 inline void slice_array<_Tp>::operator&=(const _Expr& __v) const {
1181 value_type* __t = __vp_;
1182 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1186 template <class _Tp>
1187 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1188 inline void slice_array<_Tp>::operator|=(const _Expr& __v) const {
1189 value_type* __t = __vp_;
1190 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1194 template <class _Tp>
1195 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1196 inline void slice_array<_Tp>::operator<<=(const _Expr& __v) const {
1197 value_type* __t = __vp_;
1198 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1202 template <class _Tp>
1203 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1204 inline void slice_array<_Tp>::operator>>=(const _Expr& __v) const {
1205 value_type* __t = __vp_;
1206 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1210 template <class _Tp>
1211 inline void slice_array<_Tp>::operator=(const value_type& __x) const {
1212 value_type* __t = __vp_;
1213 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1219 class _LIBCPP_EXPORTED_FROM_ABI gslice {
1220 valarray<size_t> __size_;
1221 valarray<size_t> __stride_;
1222 valarray<size_t> __1d_;
1225 _LIBCPP_HIDE_FROM_ABI gslice() {}
1227 _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, const valarray<size_t>& __stride)
1228 : __size_(__size), __stride_(__stride) {
1232 # ifndef _LIBCPP_CXX03_LANG
1234 _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, valarray<size_t>&& __stride)
1235 : __size_(__size), __stride_(std::move(__stride)) {
1239 _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, valarray<size_t>&& __size, const valarray<size_t>& __stride)
1240 : __size_(std::move(__size)), __stride_(__stride) {
1244 _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, valarray<size_t>&& __size, valarray<size_t>&& __stride)
1245 : __size_(std::move(__size)), __stride_(std::move(__stride)) {
1249 # endif // _LIBCPP_CXX03_LANG
1251 _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; }
1253 _LIBCPP_HIDE_FROM_ABI valarray<size_t> size() const { return __size_; }
1255 _LIBCPP_HIDE_FROM_ABI valarray<size_t> stride() const { return __stride_; }
1258 void __init(size_t __start);
1261 friend class gslice_array;
1263 friend class valarray;
1265 friend class __val_expr;
1270 template <class _Tp>
1271 class _LIBCPP_TEMPLATE_VIS gslice_array {
1273 typedef _Tp value_type;
1277 valarray<size_t> __1d_;
1280 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1281 void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;
1283 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1284 void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;
1286 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1287 void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;
1289 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1290 void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;
1292 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1293 void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;
1295 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1296 void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;
1298 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1299 void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;
1301 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1302 void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;
1304 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1305 void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;
1307 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1308 void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;
1310 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1311 void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;
1313 _LIBCPP_HIDE_FROM_ABI const gslice_array& operator=(const gslice_array& __ga) const;
1315 _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
1317 gslice_array(const gslice_array&) = default;
1319 // Behaves like __val_expr::operator[], which returns by value.
1320 _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1321 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "gslice_array.__get() index out of bounds");
1322 return __vp_[__1d_[__i]];
1326 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1327 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {}
1329 # ifndef _LIBCPP_CXX03_LANG
1330 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1331 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__gs.__1d_)) {}
1332 # endif // _LIBCPP_CXX03_LANG
1335 friend class valarray;
1338 template <class _Tp>
1339 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1340 inline void gslice_array<_Tp>::operator=(const _Expr& __v) const {
1341 typedef const size_t* _Ip;
1343 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1344 __vp_[*__i] = __v[__j];
1347 template <class _Tp>
1348 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1349 inline void gslice_array<_Tp>::operator*=(const _Expr& __v) const {
1350 typedef const size_t* _Ip;
1352 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1353 __vp_[*__i] *= __v[__j];
1356 template <class _Tp>
1357 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1358 inline void gslice_array<_Tp>::operator/=(const _Expr& __v) const {
1359 typedef const size_t* _Ip;
1361 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1362 __vp_[*__i] /= __v[__j];
1365 template <class _Tp>
1366 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1367 inline void gslice_array<_Tp>::operator%=(const _Expr& __v) const {
1368 typedef const size_t* _Ip;
1370 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1371 __vp_[*__i] %= __v[__j];
1374 template <class _Tp>
1375 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1376 inline void gslice_array<_Tp>::operator+=(const _Expr& __v) const {
1377 typedef const size_t* _Ip;
1379 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1380 __vp_[*__i] += __v[__j];
1383 template <class _Tp>
1384 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1385 inline void gslice_array<_Tp>::operator-=(const _Expr& __v) const {
1386 typedef const size_t* _Ip;
1388 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1389 __vp_[*__i] -= __v[__j];
1392 template <class _Tp>
1393 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1394 inline void gslice_array<_Tp>::operator^=(const _Expr& __v) const {
1395 typedef const size_t* _Ip;
1397 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1398 __vp_[*__i] ^= __v[__j];
1401 template <class _Tp>
1402 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1403 inline void gslice_array<_Tp>::operator&=(const _Expr& __v) const {
1404 typedef const size_t* _Ip;
1406 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1407 __vp_[*__i] &= __v[__j];
1410 template <class _Tp>
1411 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1412 inline void gslice_array<_Tp>::operator|=(const _Expr& __v) const {
1413 typedef const size_t* _Ip;
1415 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1416 __vp_[*__i] |= __v[__j];
1419 template <class _Tp>
1420 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1421 inline void gslice_array<_Tp>::operator<<=(const _Expr& __v) const {
1422 typedef const size_t* _Ip;
1424 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1425 __vp_[*__i] <<= __v[__j];
1428 template <class _Tp>
1429 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1430 inline void gslice_array<_Tp>::operator>>=(const _Expr& __v) const {
1431 typedef const size_t* _Ip;
1433 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1434 __vp_[*__i] >>= __v[__j];
1437 template <class _Tp>
1438 inline const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const {
1439 typedef const size_t* _Ip;
1440 const value_type* __s = __ga.__vp_;
1441 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; __i != __e; ++__i, ++__j)
1442 __vp_[*__i] = __s[*__j];
1446 template <class _Tp>
1447 inline void gslice_array<_Tp>::operator=(const value_type& __x) const {
1448 typedef const size_t* _Ip;
1449 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1455 template <class _Tp>
1456 class _LIBCPP_TEMPLATE_VIS mask_array {
1458 typedef _Tp value_type;
1462 valarray<size_t> __1d_;
1465 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1466 void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;
1468 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1469 void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;
1471 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1472 void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;
1474 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1475 void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;
1477 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1478 void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;
1480 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1481 void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;
1483 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1484 void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;
1486 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1487 void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;
1489 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1490 void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;
1492 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1493 void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;
1495 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1496 void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;
1498 mask_array(const mask_array&) = default;
1500 _LIBCPP_HIDE_FROM_ABI const mask_array& operator=(const mask_array& __ma) const;
1502 _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
1504 // Behaves like __val_expr::operator[], which returns by value.
1505 _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1506 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "mask_array.__get() index out of bounds");
1507 return __vp_[__1d_[__i]];
1511 _LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1512 : __vp_(const_cast<value_type*>(__v.__begin_)),
1513 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) {
1515 for (size_t __i = 0; __i < __vb.size(); ++__i)
1521 friend class valarray;
1524 template <class _Tp>
1525 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1526 inline void mask_array<_Tp>::operator=(const _Expr& __v) const {
1527 size_t __n = __1d_.size();
1528 for (size_t __i = 0; __i < __n; ++__i)
1529 __vp_[__1d_[__i]] = __v[__i];
1532 template <class _Tp>
1533 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1534 inline void mask_array<_Tp>::operator*=(const _Expr& __v) const {
1535 size_t __n = __1d_.size();
1536 for (size_t __i = 0; __i < __n; ++__i)
1537 __vp_[__1d_[__i]] *= __v[__i];
1540 template <class _Tp>
1541 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1542 inline void mask_array<_Tp>::operator/=(const _Expr& __v) const {
1543 size_t __n = __1d_.size();
1544 for (size_t __i = 0; __i < __n; ++__i)
1545 __vp_[__1d_[__i]] /= __v[__i];
1548 template <class _Tp>
1549 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1550 inline void mask_array<_Tp>::operator%=(const _Expr& __v) const {
1551 size_t __n = __1d_.size();
1552 for (size_t __i = 0; __i < __n; ++__i)
1553 __vp_[__1d_[__i]] %= __v[__i];
1556 template <class _Tp>
1557 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1558 inline void mask_array<_Tp>::operator+=(const _Expr& __v) const {
1559 size_t __n = __1d_.size();
1560 for (size_t __i = 0; __i < __n; ++__i)
1561 __vp_[__1d_[__i]] += __v[__i];
1564 template <class _Tp>
1565 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1566 inline void mask_array<_Tp>::operator-=(const _Expr& __v) const {
1567 size_t __n = __1d_.size();
1568 for (size_t __i = 0; __i < __n; ++__i)
1569 __vp_[__1d_[__i]] -= __v[__i];
1572 template <class _Tp>
1573 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1574 inline void mask_array<_Tp>::operator^=(const _Expr& __v) const {
1575 size_t __n = __1d_.size();
1576 for (size_t __i = 0; __i < __n; ++__i)
1577 __vp_[__1d_[__i]] ^= __v[__i];
1580 template <class _Tp>
1581 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1582 inline void mask_array<_Tp>::operator&=(const _Expr& __v) const {
1583 size_t __n = __1d_.size();
1584 for (size_t __i = 0; __i < __n; ++__i)
1585 __vp_[__1d_[__i]] &= __v[__i];
1588 template <class _Tp>
1589 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1590 inline void mask_array<_Tp>::operator|=(const _Expr& __v) const {
1591 size_t __n = __1d_.size();
1592 for (size_t __i = 0; __i < __n; ++__i)
1593 __vp_[__1d_[__i]] |= __v[__i];
1596 template <class _Tp>
1597 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1598 inline void mask_array<_Tp>::operator<<=(const _Expr& __v) const {
1599 size_t __n = __1d_.size();
1600 for (size_t __i = 0; __i < __n; ++__i)
1601 __vp_[__1d_[__i]] <<= __v[__i];
1604 template <class _Tp>
1605 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1606 inline void mask_array<_Tp>::operator>>=(const _Expr& __v) const {
1607 size_t __n = __1d_.size();
1608 for (size_t __i = 0; __i < __n; ++__i)
1609 __vp_[__1d_[__i]] >>= __v[__i];
1612 template <class _Tp>
1613 inline const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const {
1614 size_t __n = __1d_.size();
1615 for (size_t __i = 0; __i < __n; ++__i)
1616 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
1620 template <class _Tp>
1621 inline void mask_array<_Tp>::operator=(const value_type& __x) const {
1622 size_t __n = __1d_.size();
1623 for (size_t __i = 0; __i < __n; ++__i)
1624 __vp_[__1d_[__i]] = __x;
1627 template <class _ValExpr>
1629 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
1632 typedef typename _RmExpr::value_type value_type;
1633 typedef value_type __result_type;
1637 valarray<size_t> __1d_;
1639 _LIBCPP_HIDE_FROM_ABI __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
1640 : __expr_(__e), __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) {
1642 for (size_t __i = 0; __i < __vb.size(); ++__i)
1648 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }
1650 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); }
1653 friend class __val_expr;
1655 friend class valarray;
1660 template <class _Tp>
1661 class _LIBCPP_TEMPLATE_VIS indirect_array {
1663 typedef _Tp value_type;
1667 valarray<size_t> __1d_;
1670 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1671 void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;
1673 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1674 void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;
1676 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1677 void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;
1679 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1680 void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;
1682 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1683 void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;
1685 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1686 void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;
1688 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1689 void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;
1691 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1692 void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;
1694 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1695 void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;
1697 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1698 void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;
1700 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1701 void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;
1703 indirect_array(const indirect_array&) = default;
1705 _LIBCPP_HIDE_FROM_ABI const indirect_array& operator=(const indirect_array& __ia) const;
1707 _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
1709 // Behaves like __val_expr::operator[], which returns by value.
1710 _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1711 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "indirect_array.__get() index out of bounds");
1712 return __vp_[__1d_[__i]];
1716 _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
1717 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {}
1719 # ifndef _LIBCPP_CXX03_LANG
1721 _LIBCPP_HIDE_FROM_ABI indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
1722 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__ia)) {}
1724 # endif // _LIBCPP_CXX03_LANG
1727 friend class valarray;
1730 template <class _Tp>
1731 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1732 inline void indirect_array<_Tp>::operator=(const _Expr& __v) const {
1733 size_t __n = __1d_.size();
1734 for (size_t __i = 0; __i < __n; ++__i)
1735 __vp_[__1d_[__i]] = __v[__i];
1738 template <class _Tp>
1739 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1740 inline void indirect_array<_Tp>::operator*=(const _Expr& __v) const {
1741 size_t __n = __1d_.size();
1742 for (size_t __i = 0; __i < __n; ++__i)
1743 __vp_[__1d_[__i]] *= __v[__i];
1746 template <class _Tp>
1747 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1748 inline void indirect_array<_Tp>::operator/=(const _Expr& __v) const {
1749 size_t __n = __1d_.size();
1750 for (size_t __i = 0; __i < __n; ++__i)
1751 __vp_[__1d_[__i]] /= __v[__i];
1754 template <class _Tp>
1755 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1756 inline void indirect_array<_Tp>::operator%=(const _Expr& __v) const {
1757 size_t __n = __1d_.size();
1758 for (size_t __i = 0; __i < __n; ++__i)
1759 __vp_[__1d_[__i]] %= __v[__i];
1762 template <class _Tp>
1763 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1764 inline void indirect_array<_Tp>::operator+=(const _Expr& __v) const {
1765 size_t __n = __1d_.size();
1766 for (size_t __i = 0; __i < __n; ++__i)
1767 __vp_[__1d_[__i]] += __v[__i];
1770 template <class _Tp>
1771 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1772 inline void indirect_array<_Tp>::operator-=(const _Expr& __v) const {
1773 size_t __n = __1d_.size();
1774 for (size_t __i = 0; __i < __n; ++__i)
1775 __vp_[__1d_[__i]] -= __v[__i];
1778 template <class _Tp>
1779 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1780 inline void indirect_array<_Tp>::operator^=(const _Expr& __v) const {
1781 size_t __n = __1d_.size();
1782 for (size_t __i = 0; __i < __n; ++__i)
1783 __vp_[__1d_[__i]] ^= __v[__i];
1786 template <class _Tp>
1787 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1788 inline void indirect_array<_Tp>::operator&=(const _Expr& __v) const {
1789 size_t __n = __1d_.size();
1790 for (size_t __i = 0; __i < __n; ++__i)
1791 __vp_[__1d_[__i]] &= __v[__i];
1794 template <class _Tp>
1795 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1796 inline void indirect_array<_Tp>::operator|=(const _Expr& __v) const {
1797 size_t __n = __1d_.size();
1798 for (size_t __i = 0; __i < __n; ++__i)
1799 __vp_[__1d_[__i]] |= __v[__i];
1802 template <class _Tp>
1803 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1804 inline void indirect_array<_Tp>::operator<<=(const _Expr& __v) const {
1805 size_t __n = __1d_.size();
1806 for (size_t __i = 0; __i < __n; ++__i)
1807 __vp_[__1d_[__i]] <<= __v[__i];
1810 template <class _Tp>
1811 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1812 inline void indirect_array<_Tp>::operator>>=(const _Expr& __v) const {
1813 size_t __n = __1d_.size();
1814 for (size_t __i = 0; __i < __n; ++__i)
1815 __vp_[__1d_[__i]] >>= __v[__i];
1818 template <class _Tp>
1819 inline const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const {
1820 typedef const size_t* _Ip;
1821 const value_type* __s = __ia.__vp_;
1822 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; __i != __e; ++__i, ++__j)
1823 __vp_[*__i] = __s[*__j];
1827 template <class _Tp>
1828 inline void indirect_array<_Tp>::operator=(const value_type& __x) const {
1829 typedef const size_t* _Ip;
1830 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1834 template <class _ValExpr>
1835 class __indirect_expr {
1836 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
1839 typedef typename _RmExpr::value_type value_type;
1840 typedef value_type __result_type;
1844 valarray<size_t> __1d_;
1846 _LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {}
1848 # ifndef _LIBCPP_CXX03_LANG
1850 _LIBCPP_HIDE_FROM_ABI __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
1851 : __expr_(__e), __1d_(std::move(__ia)) {}
1853 # endif // _LIBCPP_CXX03_LANG
1856 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }
1858 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); }
1861 friend class __val_expr;
1863 friend class _LIBCPP_TEMPLATE_VIS valarray;
1866 template <class _ValExpr>
1868 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
1873 typedef typename _RmExpr::value_type value_type;
1874 typedef typename _RmExpr::__result_type __result_type;
1876 _LIBCPP_HIDE_FROM_ABI explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
1878 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__i]; }
1880 _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const {
1881 typedef __slice_expr<_ValExpr> _NewExpr;
1882 return __val_expr< _NewExpr >(_NewExpr(__s, __expr_));
1885 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const {
1886 typedef __indirect_expr<_ValExpr> _NewExpr;
1887 return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_));
1890 _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const {
1891 typedef __mask_expr<_ValExpr> _NewExpr;
1892 return __val_expr< _NewExpr >(_NewExpr(__vb, __expr_));
1895 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const {
1896 typedef __indirect_expr<_ValExpr> _NewExpr;
1897 return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_));
1900 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > operator+() const {
1901 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
1902 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
1905 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > operator-() const {
1906 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
1907 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
1910 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > operator~() const {
1911 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
1912 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
1915 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > operator!() const {
1916 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
1917 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
1920 operator valarray<__result_type>() const;
1922 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __expr_.size(); }
1924 _LIBCPP_HIDE_FROM_ABI __result_type sum() const {
1925 size_t __n = __expr_.size();
1926 __result_type __r = __n ? __expr_[0] : __result_type();
1927 for (size_t __i = 1; __i < __n; ++__i)
1928 __r += __expr_[__i];
1932 _LIBCPP_HIDE_FROM_ABI __result_type min() const {
1933 size_t __n = size();
1934 __result_type __r = __n ? (*this)[0] : __result_type();
1935 for (size_t __i = 1; __i < __n; ++__i) {
1936 __result_type __x = __expr_[__i];
1943 _LIBCPP_HIDE_FROM_ABI __result_type max() const {
1944 size_t __n = size();
1945 __result_type __r = __n ? (*this)[0] : __result_type();
1946 for (size_t __i = 1; __i < __n; ++__i) {
1947 __result_type __x = __expr_[__i];
1954 _LIBCPP_HIDE_FROM_ABI __val_expr<__shift_expr<_ValExpr> > shift(int __i) const {
1955 return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));
1958 _LIBCPP_HIDE_FROM_ABI __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const {
1959 return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));
1962 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(value_type)>, _ValExpr> >
1963 apply(value_type __f(value_type)) const {
1964 typedef __apply_expr<value_type, value_type (*)(value_type)> _Op;
1965 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
1966 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
1969 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(const value_type&)>, _ValExpr> >
1970 apply(value_type __f(const value_type&)) const {
1971 typedef __apply_expr<value_type, value_type (*)(const value_type&)> _Op;
1972 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
1973 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
1977 template <class _ValExpr>
1978 __val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const {
1979 valarray<__result_type> __r;
1980 size_t __n = __expr_.size();
1982 __r.__begin_ = __r.__end_ = allocator<__result_type>().allocate(__n);
1983 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
1984 ::new ((void*)__r.__end_) __result_type(__expr_[__i]);
1991 template <class _Tp>
1992 inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) {
1994 __begin_ = __end_ = allocator<value_type>().allocate(__n);
1995 # if _LIBCPP_HAS_EXCEPTIONS
1997 # endif // _LIBCPP_HAS_EXCEPTIONS
1998 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
1999 ::new ((void*)__end_) value_type();
2000 # if _LIBCPP_HAS_EXCEPTIONS
2005 # endif // _LIBCPP_HAS_EXCEPTIONS
2009 template <class _Tp>
2010 inline valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(nullptr), __end_(nullptr) {
2014 template <class _Tp>
2015 valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) {
2017 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2018 # if _LIBCPP_HAS_EXCEPTIONS
2020 # endif // _LIBCPP_HAS_EXCEPTIONS
2021 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
2022 ::new ((void*)__end_) value_type(*__p);
2023 # if _LIBCPP_HAS_EXCEPTIONS
2028 # endif // _LIBCPP_HAS_EXCEPTIONS
2032 template <class _Tp>
2033 valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) {
2035 __begin_ = __end_ = allocator<value_type>().allocate(__v.size());
2036 # if _LIBCPP_HAS_EXCEPTIONS
2038 # endif // _LIBCPP_HAS_EXCEPTIONS
2039 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2040 ::new ((void*)__end_) value_type(*__p);
2041 # if _LIBCPP_HAS_EXCEPTIONS
2043 __clear(__v.size());
2046 # endif // _LIBCPP_HAS_EXCEPTIONS
2050 # ifndef _LIBCPP_CXX03_LANG
2052 template <class _Tp>
2053 inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) {
2054 __v.__begin_ = __v.__end_ = nullptr;
2057 template <class _Tp>
2058 valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr), __end_(nullptr) {
2059 const size_t __n = __il.size();
2061 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2062 # if _LIBCPP_HAS_EXCEPTIONS
2064 # endif // _LIBCPP_HAS_EXCEPTIONS
2065 size_t __n_left = __n;
2066 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
2067 ::new ((void*)__end_) value_type(*__p);
2068 # if _LIBCPP_HAS_EXCEPTIONS
2073 # endif // _LIBCPP_HAS_EXCEPTIONS
2077 # endif // _LIBCPP_CXX03_LANG
2079 template <class _Tp>
2080 valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) {
2081 const size_t __n = __sa.__size_;
2083 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2084 # if _LIBCPP_HAS_EXCEPTIONS
2086 # endif // _LIBCPP_HAS_EXCEPTIONS
2087 size_t __n_left = __n;
2088 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
2089 ::new ((void*)__end_) value_type(*__p);
2090 # if _LIBCPP_HAS_EXCEPTIONS
2095 # endif // _LIBCPP_HAS_EXCEPTIONS
2099 template <class _Tp>
2100 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr), __end_(nullptr) {
2101 const size_t __n = __ga.__1d_.size();
2103 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2104 # if _LIBCPP_HAS_EXCEPTIONS
2106 # endif // _LIBCPP_HAS_EXCEPTIONS
2107 typedef const size_t* _Ip;
2108 const value_type* __s = __ga.__vp_;
2109 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_)
2110 ::new ((void*)__end_) value_type(__s[*__i]);
2111 # if _LIBCPP_HAS_EXCEPTIONS
2116 # endif // _LIBCPP_HAS_EXCEPTIONS
2120 template <class _Tp>
2121 valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), __end_(nullptr) {
2122 const size_t __n = __ma.__1d_.size();
2124 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2125 # if _LIBCPP_HAS_EXCEPTIONS
2127 # endif // _LIBCPP_HAS_EXCEPTIONS
2128 typedef const size_t* _Ip;
2129 const value_type* __s = __ma.__vp_;
2130 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_)
2131 ::new ((void*)__end_) value_type(__s[*__i]);
2132 # if _LIBCPP_HAS_EXCEPTIONS
2137 # endif // _LIBCPP_HAS_EXCEPTIONS
2141 template <class _Tp>
2142 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullptr), __end_(nullptr) {
2143 const size_t __n = __ia.__1d_.size();
2145 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2146 # if _LIBCPP_HAS_EXCEPTIONS
2148 # endif // _LIBCPP_HAS_EXCEPTIONS
2149 typedef const size_t* _Ip;
2150 const value_type* __s = __ia.__vp_;
2151 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_)
2152 ::new ((void*)__end_) value_type(__s[*__i]);
2153 # if _LIBCPP_HAS_EXCEPTIONS
2158 # endif // _LIBCPP_HAS_EXCEPTIONS
2162 template <class _Tp>
2163 inline valarray<_Tp>::~valarray() {
2167 template <class _Tp>
2168 valarray<_Tp>& valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) {
2169 size_t __n = __l - __f;
2170 if (size() != __n) {
2172 __begin_ = allocator<value_type>().allocate(__n);
2173 __end_ = __begin_ + __n;
2174 std::uninitialized_copy(__f, __l, __begin_);
2176 std::copy(__f, __l, __begin_);
2181 template <class _Tp>
2182 valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) {
2183 if (this != std::addressof(__v))
2184 return __assign_range(__v.__begin_, __v.__end_);
2188 # ifndef _LIBCPP_CXX03_LANG
2190 template <class _Tp>
2191 inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT {
2193 __begin_ = __v.__begin_;
2194 __end_ = __v.__end_;
2195 __v.__begin_ = nullptr;
2196 __v.__end_ = nullptr;
2200 template <class _Tp>
2201 inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list<value_type> __il) {
2202 return __assign_range(__il.begin(), __il.end());
2205 # endif // _LIBCPP_CXX03_LANG
2207 template <class _Tp>
2208 inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) {
2209 std::fill(__begin_, __end_, __x);
2213 template <class _Tp>
2214 inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<value_type>& __sa) {
2215 value_type* __t = __begin_;
2216 const value_type* __s = __sa.__vp_;
2217 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
2222 template <class _Tp>
2223 inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) {
2224 typedef const size_t* _Ip;
2225 value_type* __t = __begin_;
2226 const value_type* __s = __ga.__vp_;
2227 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__t)
2232 template <class _Tp>
2233 inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<value_type>& __ma) {
2234 typedef const size_t* _Ip;
2235 value_type* __t = __begin_;
2236 const value_type* __s = __ma.__vp_;
2237 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__t)
2242 template <class _Tp>
2243 inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) {
2244 typedef const size_t* _Ip;
2245 value_type* __t = __begin_;
2246 const value_type* __s = __ia.__vp_;
2247 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__t)
2252 template <class _Tp>
2253 template <class _ValExpr>
2254 inline valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) {
2255 size_t __n = __v.size();
2258 value_type* __t = __begin_;
2259 for (size_t __i = 0; __i != __n; ++__t, ++__i)
2260 *__t = __result_type(__v[__i]);
2264 template <class _Tp>
2265 inline __val_expr<__slice_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](slice __s) const {
2266 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
2269 template <class _Tp>
2270 inline slice_array<_Tp> valarray<_Tp>::operator[](slice __s) {
2271 return slice_array<value_type>(__s, *this);
2274 template <class _Tp>
2275 inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const gslice& __gs) const {
2276 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
2279 template <class _Tp>
2280 inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) {
2281 return gslice_array<value_type>(__gs, *this);
2284 # ifndef _LIBCPP_CXX03_LANG
2286 template <class _Tp>
2287 inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](gslice&& __gs) const {
2288 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this));
2291 template <class _Tp>
2292 inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) {
2293 return gslice_array<value_type>(std::move(__gs), *this);
2296 # endif // _LIBCPP_CXX03_LANG
2298 template <class _Tp>
2299 inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const {
2300 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
2303 template <class _Tp>
2304 inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) {
2305 return mask_array<value_type>(__vb, *this);
2308 # ifndef _LIBCPP_CXX03_LANG
2310 template <class _Tp>
2311 inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<bool>&& __vb) const {
2312 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this));
2315 template <class _Tp>
2316 inline mask_array<_Tp> valarray<_Tp>::operator[](valarray<bool>&& __vb) {
2317 return mask_array<value_type>(std::move(__vb), *this);
2320 # endif // _LIBCPP_CXX03_LANG
2322 template <class _Tp>
2323 inline __val_expr<__indirect_expr<const valarray<_Tp>&> >
2324 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const {
2325 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
2328 template <class _Tp>
2329 inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __vs) {
2330 return indirect_array<value_type>(__vs, *this);
2333 # ifndef _LIBCPP_CXX03_LANG
2335 template <class _Tp>
2336 inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<size_t>&& __vs) const {
2337 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this));
2340 template <class _Tp>
2341 inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray<size_t>&& __vs) {
2342 return indirect_array<value_type>(std::move(__vs), *this);
2345 # endif // _LIBCPP_CXX03_LANG
2347 template <class _Tp>
2348 inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const {
2349 using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>;
2350 return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this));
2353 template <class _Tp>
2354 inline __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator-() const {
2355 using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>;
2356 return __val_expr<_Op>(_Op(negate<_Tp>(), *this));
2359 template <class _Tp>
2360 inline __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator~() const {
2361 using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>;
2362 return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this));
2365 template <class _Tp>
2366 inline __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator!() const {
2367 using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>;
2368 return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this));
2371 template <class _Tp>
2372 inline valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) {
2373 for (value_type* __p = __begin_; __p != __end_; ++__p)
2378 template <class _Tp>
2379 inline valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) {
2380 for (value_type* __p = __begin_; __p != __end_; ++__p)
2385 template <class _Tp>
2386 inline valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) {
2387 for (value_type* __p = __begin_; __p != __end_; ++__p)
2392 template <class _Tp>
2393 inline valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) {
2394 for (value_type* __p = __begin_; __p != __end_; ++__p)
2399 template <class _Tp>
2400 inline valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) {
2401 for (value_type* __p = __begin_; __p != __end_; ++__p)
2406 template <class _Tp>
2407 inline valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) {
2408 for (value_type* __p = __begin_; __p != __end_; ++__p)
2413 template <class _Tp>
2414 inline valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) {
2415 for (value_type* __p = __begin_; __p != __end_; ++__p)
2420 template <class _Tp>
2421 inline valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) {
2422 for (value_type* __p = __begin_; __p != __end_; ++__p)
2427 template <class _Tp>
2428 inline valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) {
2429 for (value_type* __p = __begin_; __p != __end_; ++__p)
2434 template <class _Tp>
2435 inline valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) {
2436 for (value_type* __p = __begin_; __p != __end_; ++__p)
2441 template <class _Tp>
2442 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2443 inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) {
2445 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2446 *__t *= std::__get(__v, __i);
2450 template <class _Tp>
2451 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2452 inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) {
2454 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2455 *__t /= std::__get(__v, __i);
2459 template <class _Tp>
2460 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2461 inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) {
2463 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2464 *__t %= std::__get(__v, __i);
2468 template <class _Tp>
2469 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2470 inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) {
2472 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2473 *__t += std::__get(__v, __i);
2477 template <class _Tp>
2478 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2479 inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) {
2481 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2482 *__t -= std::__get(__v, __i);
2486 template <class _Tp>
2487 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2488 inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) {
2490 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2491 *__t ^= std::__get(__v, __i);
2495 template <class _Tp>
2496 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2497 inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) {
2499 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2500 *__t |= std::__get(__v, __i);
2504 template <class _Tp>
2505 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2506 inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) {
2508 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2509 *__t &= std::__get(__v, __i);
2513 template <class _Tp>
2514 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2515 inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) {
2517 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2518 *__t <<= std::__get(__v, __i);
2522 template <class _Tp>
2523 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2524 inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) {
2526 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2527 *__t >>= std::__get(__v, __i);
2531 template <class _Tp>
2532 inline void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT {
2533 std::swap(__begin_, __v.__begin_);
2534 std::swap(__end_, __v.__end_);
2537 template <class _Tp>
2538 inline _Tp valarray<_Tp>::sum() const {
2539 if (__begin_ == __end_)
2540 return value_type();
2541 const value_type* __p = __begin_;
2543 for (++__p; __p != __end_; ++__p)
2548 template <class _Tp>
2549 inline _Tp valarray<_Tp>::min() const {
2550 if (__begin_ == __end_)
2551 return value_type();
2552 return *std::min_element(__begin_, __end_);
2555 template <class _Tp>
2556 inline _Tp valarray<_Tp>::max() const {
2557 if (__begin_ == __end_)
2558 return value_type();
2559 return *std::max_element(__begin_, __end_);
2562 template <class _Tp>
2563 valarray<_Tp> valarray<_Tp>::shift(int __i) const {
2564 valarray<value_type> __r;
2565 size_t __n = size();
2567 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
2568 const value_type* __sb;
2572 __i = std::min(__i, static_cast<int>(__n));
2573 __sb = __begin_ + __i;
2574 __tb = __r.__begin_;
2575 __te = __r.__begin_ + (__n - __i);
2577 __i = std::min(-__i, static_cast<int>(__n));
2579 __tb = __r.__begin_ + __i;
2580 __te = __r.__begin_ + __n;
2582 for (; __r.__end_ != __tb; ++__r.__end_)
2583 ::new ((void*)__r.__end_) value_type();
2584 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
2585 ::new ((void*)__r.__end_) value_type(*__sb);
2586 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
2587 ::new ((void*)__r.__end_) value_type();
2592 template <class _Tp>
2593 valarray<_Tp> valarray<_Tp>::cshift(int __i) const {
2594 valarray<value_type> __r;
2595 size_t __n = size();
2597 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
2598 __i %= static_cast<int>(__n);
2599 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
2600 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
2601 ::new ((void*)__r.__end_) value_type(*__s);
2602 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
2603 ::new ((void*)__r.__end_) value_type(*__s);
2608 template <class _Tp>
2609 valarray<_Tp> valarray<_Tp>::apply(value_type __f(value_type)) const {
2610 valarray<value_type> __r;
2611 size_t __n = size();
2613 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
2614 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
2615 ::new ((void*)__r.__end_) value_type(__f(*__p));
2620 template <class _Tp>
2621 valarray<_Tp> valarray<_Tp>::apply(value_type __f(const value_type&)) const {
2622 valarray<value_type> __r;
2623 size_t __n = size();
2625 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
2626 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
2627 ::new ((void*)__r.__end_) value_type(__f(*__p));
2632 template <class _Tp>
2633 inline void valarray<_Tp>::__clear(size_t __capacity) {
2634 if (__begin_ != nullptr) {
2635 while (__end_ != __begin_)
2636 (--__end_)->~value_type();
2637 allocator<value_type>().deallocate(__begin_, __capacity);
2638 __begin_ = __end_ = nullptr;
2642 template <class _Tp>
2643 void valarray<_Tp>::resize(size_t __n, value_type __x) {
2646 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2647 # if _LIBCPP_HAS_EXCEPTIONS
2649 # endif // _LIBCPP_HAS_EXCEPTIONS
2650 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
2651 ::new ((void*)__end_) value_type(__x);
2652 # if _LIBCPP_HAS_EXCEPTIONS
2657 # endif // _LIBCPP_HAS_EXCEPTIONS
2661 template <class _Tp>
2662 inline _LIBCPP_HIDE_FROM_ABI void swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT {
2666 template <class _Expr1,
2668 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2669 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
2670 operator*(const _Expr1& __x, const _Expr2& __y) {
2671 typedef typename _Expr1::value_type value_type;
2672 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
2673 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
2676 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2677 inline _LIBCPP_HIDE_FROM_ABI
2678 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2679 operator*(const _Expr& __x, const typename _Expr::value_type& __y) {
2680 typedef typename _Expr::value_type value_type;
2681 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2682 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2685 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2686 inline _LIBCPP_HIDE_FROM_ABI
2687 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2688 operator*(const typename _Expr::value_type& __x, const _Expr& __y) {
2689 typedef typename _Expr::value_type value_type;
2690 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2691 return __val_expr<_Op>(_Op(multiplies<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2694 template <class _Expr1,
2696 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2697 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
2698 operator/(const _Expr1& __x, const _Expr2& __y) {
2699 typedef typename _Expr1::value_type value_type;
2700 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
2701 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
2704 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2705 inline _LIBCPP_HIDE_FROM_ABI
2706 __val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2707 operator/(const _Expr& __x, const typename _Expr::value_type& __y) {
2708 typedef typename _Expr::value_type value_type;
2709 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2710 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2713 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2714 inline _LIBCPP_HIDE_FROM_ABI
2715 __val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2716 operator/(const typename _Expr::value_type& __x, const _Expr& __y) {
2717 typedef typename _Expr::value_type value_type;
2718 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2719 return __val_expr<_Op>(_Op(divides<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2722 template <class _Expr1,
2724 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2725 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
2726 operator%(const _Expr1& __x, const _Expr2& __y) {
2727 typedef typename _Expr1::value_type value_type;
2728 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
2729 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
2732 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2733 inline _LIBCPP_HIDE_FROM_ABI
2734 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2735 operator%(const _Expr& __x, const typename _Expr::value_type& __y) {
2736 typedef typename _Expr::value_type value_type;
2737 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2738 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2741 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2742 inline _LIBCPP_HIDE_FROM_ABI
2743 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2744 operator%(const typename _Expr::value_type& __x, const _Expr& __y) {
2745 typedef typename _Expr::value_type value_type;
2746 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2747 return __val_expr<_Op>(_Op(modulus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2750 template <class _Expr1,
2752 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2753 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
2754 operator+(const _Expr1& __x, const _Expr2& __y) {
2755 typedef typename _Expr1::value_type value_type;
2756 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
2757 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
2760 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2761 inline _LIBCPP_HIDE_FROM_ABI
2762 __val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2763 operator+(const _Expr& __x, const typename _Expr::value_type& __y) {
2764 typedef typename _Expr::value_type value_type;
2765 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2766 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2769 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2770 inline _LIBCPP_HIDE_FROM_ABI
2771 __val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2772 operator+(const typename _Expr::value_type& __x, const _Expr& __y) {
2773 typedef typename _Expr::value_type value_type;
2774 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2775 return __val_expr<_Op>(_Op(plus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2778 template <class _Expr1,
2780 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2781 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
2782 operator-(const _Expr1& __x, const _Expr2& __y) {
2783 typedef typename _Expr1::value_type value_type;
2784 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
2785 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
2788 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2789 inline _LIBCPP_HIDE_FROM_ABI
2790 __val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2791 operator-(const _Expr& __x, const typename _Expr::value_type& __y) {
2792 typedef typename _Expr::value_type value_type;
2793 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2794 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2797 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2798 inline _LIBCPP_HIDE_FROM_ABI
2799 __val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2800 operator-(const typename _Expr::value_type& __x, const _Expr& __y) {
2801 typedef typename _Expr::value_type value_type;
2802 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2803 return __val_expr<_Op>(_Op(minus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2806 template <class _Expr1,
2808 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2809 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
2810 operator^(const _Expr1& __x, const _Expr2& __y) {
2811 typedef typename _Expr1::value_type value_type;
2812 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
2813 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
2816 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2817 inline _LIBCPP_HIDE_FROM_ABI
2818 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2819 operator^(const _Expr& __x, const typename _Expr::value_type& __y) {
2820 typedef typename _Expr::value_type value_type;
2821 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2822 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2825 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2826 inline _LIBCPP_HIDE_FROM_ABI
2827 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2828 operator^(const typename _Expr::value_type& __x, const _Expr& __y) {
2829 typedef typename _Expr::value_type value_type;
2830 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2831 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2834 template <class _Expr1,
2836 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2837 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
2838 operator&(const _Expr1& __x, const _Expr2& __y) {
2839 typedef typename _Expr1::value_type value_type;
2840 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
2841 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
2844 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2845 inline _LIBCPP_HIDE_FROM_ABI
2846 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2847 operator&(const _Expr& __x, const typename _Expr::value_type& __y) {
2848 typedef typename _Expr::value_type value_type;
2849 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2850 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2853 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2854 inline _LIBCPP_HIDE_FROM_ABI
2855 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2856 operator&(const typename _Expr::value_type& __x, const _Expr& __y) {
2857 typedef typename _Expr::value_type value_type;
2858 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2859 return __val_expr<_Op>(_Op(bit_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2862 template <class _Expr1,
2864 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2865 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
2866 operator|(const _Expr1& __x, const _Expr2& __y) {
2867 typedef typename _Expr1::value_type value_type;
2868 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
2869 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
2872 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2873 inline _LIBCPP_HIDE_FROM_ABI
2874 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2875 operator|(const _Expr& __x, const typename _Expr::value_type& __y) {
2876 typedef typename _Expr::value_type value_type;
2877 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2878 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2881 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2882 inline _LIBCPP_HIDE_FROM_ABI
2883 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2884 operator|(const typename _Expr::value_type& __x, const _Expr& __y) {
2885 typedef typename _Expr::value_type value_type;
2886 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2887 return __val_expr<_Op>(_Op(bit_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2890 template <class _Expr1,
2892 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2893 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
2894 operator<<(const _Expr1& __x, const _Expr2& __y) {
2895 typedef typename _Expr1::value_type value_type;
2896 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
2897 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
2900 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2901 inline _LIBCPP_HIDE_FROM_ABI
2902 __val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2903 operator<<(const _Expr& __x, const typename _Expr::value_type& __y) {
2904 typedef typename _Expr::value_type value_type;
2905 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2906 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2909 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2910 inline _LIBCPP_HIDE_FROM_ABI
2911 __val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2912 operator<<(const typename _Expr::value_type& __x, const _Expr& __y) {
2913 typedef typename _Expr::value_type value_type;
2914 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2915 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2918 template <class _Expr1,
2920 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2921 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
2922 operator>>(const _Expr1& __x, const _Expr2& __y) {
2923 typedef typename _Expr1::value_type value_type;
2924 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
2925 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
2928 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2929 inline _LIBCPP_HIDE_FROM_ABI __val_expr<
2930 _BinaryOp<__bit_shift_right<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2931 operator>>(const _Expr& __x, const typename _Expr::value_type& __y) {
2932 typedef typename _Expr::value_type value_type;
2933 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2934 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2937 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2938 inline _LIBCPP_HIDE_FROM_ABI
2939 __val_expr< _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2940 operator>>(const typename _Expr::value_type& __x, const _Expr& __y) {
2941 typedef typename _Expr::value_type value_type;
2942 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2943 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2946 template <class _Expr1,
2948 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2949 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
2950 operator&&(const _Expr1& __x, const _Expr2& __y) {
2951 typedef typename _Expr1::value_type value_type;
2952 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
2953 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
2956 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2957 inline _LIBCPP_HIDE_FROM_ABI
2958 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2959 operator&&(const _Expr& __x, const typename _Expr::value_type& __y) {
2960 typedef typename _Expr::value_type value_type;
2961 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2962 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2965 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2966 inline _LIBCPP_HIDE_FROM_ABI
2967 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2968 operator&&(const typename _Expr::value_type& __x, const _Expr& __y) {
2969 typedef typename _Expr::value_type value_type;
2970 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2971 return __val_expr<_Op>(_Op(logical_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2974 template <class _Expr1,
2976 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2977 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
2978 operator||(const _Expr1& __x, const _Expr2& __y) {
2979 typedef typename _Expr1::value_type value_type;
2980 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
2981 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
2984 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2985 inline _LIBCPP_HIDE_FROM_ABI
2986 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2987 operator||(const _Expr& __x, const typename _Expr::value_type& __y) {
2988 typedef typename _Expr::value_type value_type;
2989 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2990 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2993 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2994 inline _LIBCPP_HIDE_FROM_ABI
2995 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2996 operator||(const typename _Expr::value_type& __x, const _Expr& __y) {
2997 typedef typename _Expr::value_type value_type;
2998 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2999 return __val_expr<_Op>(_Op(logical_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3002 template <class _Expr1,
3004 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3005 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
3006 operator==(const _Expr1& __x, const _Expr2& __y) {
3007 typedef typename _Expr1::value_type value_type;
3008 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
3009 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
3012 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3013 inline _LIBCPP_HIDE_FROM_ABI
3014 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3015 operator==(const _Expr& __x, const typename _Expr::value_type& __y) {
3016 typedef typename _Expr::value_type value_type;
3017 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3018 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3021 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3022 inline _LIBCPP_HIDE_FROM_ABI
3023 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3024 operator==(const typename _Expr::value_type& __x, const _Expr& __y) {
3025 typedef typename _Expr::value_type value_type;
3026 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3027 return __val_expr<_Op>(_Op(equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3030 template <class _Expr1,
3032 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3033 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
3034 operator!=(const _Expr1& __x, const _Expr2& __y) {
3035 typedef typename _Expr1::value_type value_type;
3036 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
3037 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
3040 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3041 inline _LIBCPP_HIDE_FROM_ABI
3042 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3043 operator!=(const _Expr& __x, const typename _Expr::value_type& __y) {
3044 typedef typename _Expr::value_type value_type;
3045 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3046 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3049 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3050 inline _LIBCPP_HIDE_FROM_ABI
3051 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3052 operator!=(const typename _Expr::value_type& __x, const _Expr& __y) {
3053 typedef typename _Expr::value_type value_type;
3054 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3055 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3058 template <class _Expr1,
3060 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3061 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
3062 operator<(const _Expr1& __x, const _Expr2& __y) {
3063 typedef typename _Expr1::value_type value_type;
3064 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
3065 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
3068 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3069 inline _LIBCPP_HIDE_FROM_ABI
3070 __val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3071 operator<(const _Expr& __x, const typename _Expr::value_type& __y) {
3072 typedef typename _Expr::value_type value_type;
3073 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3074 return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3077 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3078 inline _LIBCPP_HIDE_FROM_ABI
3079 __val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3080 operator<(const typename _Expr::value_type& __x, const _Expr& __y) {
3081 typedef typename _Expr::value_type value_type;
3082 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3083 return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3086 template <class _Expr1,
3088 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3089 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
3090 operator>(const _Expr1& __x, const _Expr2& __y) {
3091 typedef typename _Expr1::value_type value_type;
3092 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
3093 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
3096 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3097 inline _LIBCPP_HIDE_FROM_ABI
3098 __val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3099 operator>(const _Expr& __x, const typename _Expr::value_type& __y) {
3100 typedef typename _Expr::value_type value_type;
3101 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3102 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3105 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3106 inline _LIBCPP_HIDE_FROM_ABI
3107 __val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3108 operator>(const typename _Expr::value_type& __x, const _Expr& __y) {
3109 typedef typename _Expr::value_type value_type;
3110 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3111 return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3114 template <class _Expr1,
3116 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3117 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
3118 operator<=(const _Expr1& __x, const _Expr2& __y) {
3119 typedef typename _Expr1::value_type value_type;
3120 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
3121 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
3124 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3125 inline _LIBCPP_HIDE_FROM_ABI
3126 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3127 operator<=(const _Expr& __x, const typename _Expr::value_type& __y) {
3128 typedef typename _Expr::value_type value_type;
3129 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3130 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3133 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3134 inline _LIBCPP_HIDE_FROM_ABI
3135 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3136 operator<=(const typename _Expr::value_type& __x, const _Expr& __y) {
3137 typedef typename _Expr::value_type value_type;
3138 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3139 return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3142 template <class _Expr1,
3144 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3145 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
3146 operator>=(const _Expr1& __x, const _Expr2& __y) {
3147 typedef typename _Expr1::value_type value_type;
3148 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
3149 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
3152 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3153 inline _LIBCPP_HIDE_FROM_ABI
3154 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3155 operator>=(const _Expr& __x, const typename _Expr::value_type& __y) {
3156 typedef typename _Expr::value_type value_type;
3157 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3158 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3161 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3162 inline _LIBCPP_HIDE_FROM_ABI
3163 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3164 operator>=(const typename _Expr::value_type& __x, const _Expr& __y) {
3165 typedef typename _Expr::value_type value_type;
3166 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3167 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3170 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3171 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
3172 abs(const _Expr& __x) {
3173 typedef typename _Expr::value_type value_type;
3174 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
3175 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
3178 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3179 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
3180 acos(const _Expr& __x) {
3181 typedef typename _Expr::value_type value_type;
3182 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
3183 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
3186 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3187 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
3188 asin(const _Expr& __x) {
3189 typedef typename _Expr::value_type value_type;
3190 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
3191 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
3194 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3195 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
3196 atan(const _Expr& __x) {
3197 typedef typename _Expr::value_type value_type;
3198 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
3199 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
3202 template <class _Expr1,
3204 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3205 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
3206 atan2(const _Expr1& __x, const _Expr2& __y) {
3207 typedef typename _Expr1::value_type value_type;
3208 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
3209 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
3212 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3213 inline _LIBCPP_HIDE_FROM_ABI
3214 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3215 atan2(const _Expr& __x, const typename _Expr::value_type& __y) {
3216 typedef typename _Expr::value_type value_type;
3217 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3218 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3221 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3222 inline _LIBCPP_HIDE_FROM_ABI
3223 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3224 atan2(const typename _Expr::value_type& __x, const _Expr& __y) {
3225 typedef typename _Expr::value_type value_type;
3226 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3227 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3230 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3231 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
3232 cos(const _Expr& __x) {
3233 typedef typename _Expr::value_type value_type;
3234 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
3235 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
3238 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3239 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
3240 cosh(const _Expr& __x) {
3241 typedef typename _Expr::value_type value_type;
3242 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
3243 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
3246 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3247 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
3248 exp(const _Expr& __x) {
3249 typedef typename _Expr::value_type value_type;
3250 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
3251 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
3254 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3255 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
3256 log(const _Expr& __x) {
3257 typedef typename _Expr::value_type value_type;
3258 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
3259 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
3262 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3263 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
3264 log10(const _Expr& __x) {
3265 typedef typename _Expr::value_type value_type;
3266 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
3267 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
3270 template <class _Expr1,
3272 __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3273 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
3274 pow(const _Expr1& __x, const _Expr2& __y) {
3275 typedef typename _Expr1::value_type value_type;
3276 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
3277 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
3280 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3281 inline _LIBCPP_HIDE_FROM_ABI
3282 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3283 pow(const _Expr& __x, const typename _Expr::value_type& __y) {
3284 typedef typename _Expr::value_type value_type;
3285 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3286 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3289 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3290 inline _LIBCPP_HIDE_FROM_ABI
3291 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3292 pow(const typename _Expr::value_type& __x, const _Expr& __y) {
3293 typedef typename _Expr::value_type value_type;
3294 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3295 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3298 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3299 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
3300 sin(const _Expr& __x) {
3301 typedef typename _Expr::value_type value_type;
3302 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
3303 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
3306 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3307 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
3308 sinh(const _Expr& __x) {
3309 typedef typename _Expr::value_type value_type;
3310 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
3311 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
3314 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3315 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
3316 sqrt(const _Expr& __x) {
3317 typedef typename _Expr::value_type value_type;
3318 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
3319 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
3322 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3323 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
3324 tan(const _Expr& __x) {
3325 typedef typename _Expr::value_type value_type;
3326 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
3327 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
3330 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3331 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
3332 tanh(const _Expr& __x) {
3333 typedef typename _Expr::value_type value_type;
3334 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
3335 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
3338 template <class _Tp>
3339 inline _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v) {
3340 return __v.__begin_;
3343 template <class _Tp>
3344 inline _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v) {
3345 return __v.__begin_;
3348 template <class _Tp>
3349 inline _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v) {
3353 template <class _Tp>
3354 inline _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v) {
3358 _LIBCPP_END_NAMESPACE_STD
3362 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
3363 # include <algorithm>
3364 # include <concepts>
3367 # include <functional>
3368 # include <stdexcept>
3369 # include <type_traits>
3371 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
3373 #endif // _LIBCPP_VALARRAY