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 #include <__algorithm/copy.h>
347 #include <__algorithm/count.h>
348 #include <__algorithm/fill.h>
349 #include <__algorithm/max_element.h>
350 #include <__algorithm/min.h>
351 #include <__algorithm/min_element.h>
352 #include <__algorithm/unwrap_iter.h>
353 #include <__assert> // all public C++ headers provide the assertion handler
355 #include <__functional/operations.h>
356 #include <__memory/addressof.h>
357 #include <__memory/allocator.h>
358 #include <__memory/uninitialized_algorithms.h>
359 #include <__type_traits/decay.h>
360 #include <__type_traits/remove_reference.h>
361 #include <__utility/move.h>
362 #include <__utility/swap.h>
368 // standard-mandated includes
371 #include <initializer_list>
373 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
374 # pragma GCC system_header
378 #include <__undef_macros>
380 _LIBCPP_BEGIN_NAMESPACE_STD
382 template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
384 class _LIBCPP_TEMPLATE_VIS slice
390 _LIBCPP_INLINE_VISIBILITY
397 _LIBCPP_INLINE_VISIBILITY
398 slice(size_t __start, size_t __size, size_t __stride)
404 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
405 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
406 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
408 #if _LIBCPP_STD_VER >= 20
410 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) {
411 return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride();
417 template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
418 class _LIBCPP_EXPORTED_FROM_ABI gslice;
419 template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
420 template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
421 template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
424 _LIBCPP_INLINE_VISIBILITY
426 begin(valarray<_Tp>& __v);
429 _LIBCPP_INLINE_VISIBILITY
431 begin(const valarray<_Tp>& __v);
434 _LIBCPP_INLINE_VISIBILITY
436 end(valarray<_Tp>& __v);
439 _LIBCPP_INLINE_VISIBILITY
441 end(const valarray<_Tp>& __v);
443 template <class _Op, class _A0>
446 typedef typename _Op::__result_type __result_type;
447 using value_type = __decay_t<__result_type>;
452 _LIBCPP_INLINE_VISIBILITY
453 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
455 _LIBCPP_INLINE_VISIBILITY
456 __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
458 _LIBCPP_INLINE_VISIBILITY
459 size_t size() const {return __a0_.size();}
462 template <class _Op, class _A0, class _A1>
465 typedef typename _Op::__result_type __result_type;
466 using value_type = __decay_t<__result_type>;
472 _LIBCPP_INLINE_VISIBILITY
473 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
474 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
476 _LIBCPP_INLINE_VISIBILITY
477 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
479 _LIBCPP_INLINE_VISIBILITY
480 size_t size() const {return __a0_.size();}
487 typedef _Tp value_type;
488 typedef const _Tp& __result_type;
490 const value_type& __t_;
493 _LIBCPP_INLINE_VISIBILITY
494 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
496 _LIBCPP_INLINE_VISIBILITY
497 __result_type operator[](size_t) const {return __t_;}
499 _LIBCPP_INLINE_VISIBILITY
500 size_t size() const {return __s_;}
506 typedef _Tp __result_type;
507 _LIBCPP_INLINE_VISIBILITY
508 _Tp operator()(const _Tp& __x) const
515 typedef _Tp __result_type;
516 _LIBCPP_INLINE_VISIBILITY
517 _Tp operator()(const _Tp& __x) const
522 struct __bit_shift_left
524 typedef _Tp __result_type;
525 _LIBCPP_INLINE_VISIBILITY
526 _Tp operator()(const _Tp& __x, const _Tp& __y) const
531 struct __bit_shift_right
533 typedef _Tp __result_type;
534 _LIBCPP_INLINE_VISIBILITY
535 _Tp operator()(const _Tp& __x, const _Tp& __y) const
539 template <class _Tp, class _Fp>
545 typedef _Tp __result_type;
547 _LIBCPP_INLINE_VISIBILITY
548 explicit __apply_expr(_Fp __f) : __f_(__f) {}
550 _LIBCPP_INLINE_VISIBILITY
551 _Tp operator()(const _Tp& __x) const
558 typedef _Tp __result_type;
559 _LIBCPP_INLINE_VISIBILITY
560 _Tp operator()(const _Tp& __x) const
561 {return std::abs(__x);}
567 typedef _Tp __result_type;
568 _LIBCPP_INLINE_VISIBILITY
569 _Tp operator()(const _Tp& __x) const
570 {return std::acos(__x);}
576 typedef _Tp __result_type;
577 _LIBCPP_INLINE_VISIBILITY
578 _Tp operator()(const _Tp& __x) const
579 {return std::asin(__x);}
585 typedef _Tp __result_type;
586 _LIBCPP_INLINE_VISIBILITY
587 _Tp operator()(const _Tp& __x) const
588 {return std::atan(__x);}
594 typedef _Tp __result_type;
595 _LIBCPP_INLINE_VISIBILITY
596 _Tp operator()(const _Tp& __x, const _Tp& __y) const
597 {return std::atan2(__x, __y);}
603 typedef _Tp __result_type;
604 _LIBCPP_INLINE_VISIBILITY
605 _Tp operator()(const _Tp& __x) const
606 {return std::cos(__x);}
612 typedef _Tp __result_type;
613 _LIBCPP_INLINE_VISIBILITY
614 _Tp operator()(const _Tp& __x) const
615 {return std::cosh(__x);}
621 typedef _Tp __result_type;
622 _LIBCPP_INLINE_VISIBILITY
623 _Tp operator()(const _Tp& __x) const
624 {return std::exp(__x);}
630 typedef _Tp __result_type;
631 _LIBCPP_INLINE_VISIBILITY
632 _Tp operator()(const _Tp& __x) const
633 {return std::log(__x);}
639 typedef _Tp __result_type;
640 _LIBCPP_INLINE_VISIBILITY
641 _Tp operator()(const _Tp& __x) const
642 {return std::log10(__x);}
648 typedef _Tp __result_type;
649 _LIBCPP_INLINE_VISIBILITY
650 _Tp operator()(const _Tp& __x, const _Tp& __y) const
651 {return std::pow(__x, __y);}
657 typedef _Tp __result_type;
658 _LIBCPP_INLINE_VISIBILITY
659 _Tp operator()(const _Tp& __x) const
660 {return std::sin(__x);}
666 typedef _Tp __result_type;
667 _LIBCPP_INLINE_VISIBILITY
668 _Tp operator()(const _Tp& __x) const
669 {return std::sinh(__x);}
675 typedef _Tp __result_type;
676 _LIBCPP_INLINE_VISIBILITY
677 _Tp operator()(const _Tp& __x) const
678 {return std::sqrt(__x);}
684 typedef _Tp __result_type;
685 _LIBCPP_INLINE_VISIBILITY
686 _Tp operator()(const _Tp& __x) const
687 {return std::tan(__x);}
693 typedef _Tp __result_type;
694 _LIBCPP_INLINE_VISIBILITY
695 _Tp operator()(const _Tp& __x) const
696 {return std::tanh(__x);}
699 template <class _ValExpr>
702 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
704 typedef typename _RmExpr::value_type value_type;
705 typedef value_type __result_type;
713 _LIBCPP_INLINE_VISIBILITY
714 __slice_expr(const slice& __sl, const _RmExpr& __e)
716 __start_(__sl.start()),
717 __size_(__sl.size()),
718 __stride_(__sl.stride())
722 _LIBCPP_INLINE_VISIBILITY
723 __result_type operator[](size_t __i) const
724 {return __expr_[__start_ + __i * __stride_];}
726 _LIBCPP_INLINE_VISIBILITY
727 size_t size() const {return __size_;}
729 template <class> friend class __val_expr;
730 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
733 template <class _ValExpr>
736 template <class _ValExpr>
737 class __indirect_expr;
739 template <class _ValExpr>
742 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
744 typedef typename _RmExpr::value_type value_type;
745 typedef value_type __result_type;
753 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
754 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
756 _LIBCPP_INLINE_VISIBILITY
757 __shift_expr(int __n, const _RmExpr& __e)
762 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
763 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
764 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
768 _LIBCPP_INLINE_VISIBILITY
769 __result_type operator[](size_t __j) const
771 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
772 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
773 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
776 _LIBCPP_INLINE_VISIBILITY
777 size_t size() const {return __size_;}
779 template <class> friend class __val_expr;
782 template <class _ValExpr>
785 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
787 typedef typename _RmExpr::value_type value_type;
788 typedef value_type __result_type;
797 _LIBCPP_INLINE_VISIBILITY
798 __cshift_expr(int __n, const _RmExpr& __e)
802 __n %= static_cast<int>(__size_);
805 __m_ = __size_ - __n;
807 __o2_ = __n - __size_;
812 __o1_ = __n + __size_;
818 _LIBCPP_INLINE_VISIBILITY
819 __result_type operator[](size_t __i) const
822 return __expr_[__i + __o1_];
823 return __expr_[__i + __o2_];
826 _LIBCPP_INLINE_VISIBILITY
827 size_t size() const {return __size_;}
829 template <class> friend class __val_expr;
832 template<class _ValExpr>
835 template<class _ValExpr>
836 struct __is_val_expr : false_type {};
838 template<class _ValExpr>
839 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
842 struct __is_val_expr<valarray<_Tp> > : true_type {};
845 class _LIBCPP_TEMPLATE_VIS valarray
848 typedef _Tp value_type;
849 typedef _Tp __result_type;
852 value_type* __begin_;
856 // construct/destroy:
857 _LIBCPP_INLINE_VISIBILITY
858 valarray() : __begin_(nullptr), __end_(nullptr) {}
859 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
860 explicit valarray(size_t __n);
861 _LIBCPP_INLINE_VISIBILITY
862 valarray(const value_type& __x, size_t __n);
863 valarray(const value_type* __p, size_t __n);
864 valarray(const valarray& __v);
865 #ifndef _LIBCPP_CXX03_LANG
866 _LIBCPP_INLINE_VISIBILITY
867 valarray(valarray&& __v) _NOEXCEPT;
868 valarray(initializer_list<value_type> __il);
869 #endif // _LIBCPP_CXX03_LANG
870 valarray(const slice_array<value_type>& __sa);
871 valarray(const gslice_array<value_type>& __ga);
872 valarray(const mask_array<value_type>& __ma);
873 valarray(const indirect_array<value_type>& __ia);
874 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
878 valarray& operator=(const valarray& __v);
879 #ifndef _LIBCPP_CXX03_LANG
880 _LIBCPP_INLINE_VISIBILITY
881 valarray& operator=(valarray&& __v) _NOEXCEPT;
882 _LIBCPP_INLINE_VISIBILITY
883 valarray& operator=(initializer_list<value_type>);
884 #endif // _LIBCPP_CXX03_LANG
885 _LIBCPP_INLINE_VISIBILITY
886 valarray& operator=(const value_type& __x);
887 _LIBCPP_INLINE_VISIBILITY
888 valarray& operator=(const slice_array<value_type>& __sa);
889 _LIBCPP_INLINE_VISIBILITY
890 valarray& operator=(const gslice_array<value_type>& __ga);
891 _LIBCPP_INLINE_VISIBILITY
892 valarray& operator=(const mask_array<value_type>& __ma);
893 _LIBCPP_INLINE_VISIBILITY
894 valarray& operator=(const indirect_array<value_type>& __ia);
895 template <class _ValExpr>
896 _LIBCPP_INLINE_VISIBILITY
897 valarray& operator=(const __val_expr<_ValExpr>& __v);
900 _LIBCPP_INLINE_VISIBILITY
901 const value_type& operator[](size_t __i) const {return __begin_[__i];}
903 _LIBCPP_INLINE_VISIBILITY
904 value_type& operator[](size_t __i) {return __begin_[__i];}
906 // subset operations:
907 _LIBCPP_INLINE_VISIBILITY
908 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
909 _LIBCPP_INLINE_VISIBILITY
910 slice_array<value_type> operator[](slice __s);
911 _LIBCPP_INLINE_VISIBILITY
912 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
913 _LIBCPP_INLINE_VISIBILITY
914 gslice_array<value_type> operator[](const gslice& __gs);
915 #ifndef _LIBCPP_CXX03_LANG
916 _LIBCPP_INLINE_VISIBILITY
917 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
918 _LIBCPP_INLINE_VISIBILITY
919 gslice_array<value_type> operator[](gslice&& __gs);
920 #endif // _LIBCPP_CXX03_LANG
921 _LIBCPP_INLINE_VISIBILITY
922 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
923 _LIBCPP_INLINE_VISIBILITY
924 mask_array<value_type> operator[](const valarray<bool>& __vb);
925 #ifndef _LIBCPP_CXX03_LANG
926 _LIBCPP_INLINE_VISIBILITY
927 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
928 _LIBCPP_INLINE_VISIBILITY
929 mask_array<value_type> operator[](valarray<bool>&& __vb);
930 #endif // _LIBCPP_CXX03_LANG
931 _LIBCPP_INLINE_VISIBILITY
932 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
933 _LIBCPP_INLINE_VISIBILITY
934 indirect_array<value_type> operator[](const valarray<size_t>& __vs);
935 #ifndef _LIBCPP_CXX03_LANG
936 _LIBCPP_INLINE_VISIBILITY
937 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
938 _LIBCPP_INLINE_VISIBILITY
939 indirect_array<value_type> operator[](valarray<size_t>&& __vs);
940 #endif // _LIBCPP_CXX03_LANG
943 _LIBCPP_INLINE_VISIBILITY
944 __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;
945 _LIBCPP_INLINE_VISIBILITY
946 __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const;
947 _LIBCPP_INLINE_VISIBILITY
948 __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const;
949 _LIBCPP_INLINE_VISIBILITY
950 __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const;
952 // computed assignment:
953 _LIBCPP_INLINE_VISIBILITY
954 valarray& operator*= (const value_type& __x);
955 _LIBCPP_INLINE_VISIBILITY
956 valarray& operator/= (const value_type& __x);
957 _LIBCPP_INLINE_VISIBILITY
958 valarray& operator%= (const value_type& __x);
959 _LIBCPP_INLINE_VISIBILITY
960 valarray& operator+= (const value_type& __x);
961 _LIBCPP_INLINE_VISIBILITY
962 valarray& operator-= (const value_type& __x);
963 _LIBCPP_INLINE_VISIBILITY
964 valarray& operator^= (const value_type& __x);
965 _LIBCPP_INLINE_VISIBILITY
966 valarray& operator&= (const value_type& __x);
967 _LIBCPP_INLINE_VISIBILITY
968 valarray& operator|= (const value_type& __x);
969 _LIBCPP_INLINE_VISIBILITY
970 valarray& operator<<=(const value_type& __x);
971 _LIBCPP_INLINE_VISIBILITY
972 valarray& operator>>=(const value_type& __x);
974 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
975 _LIBCPP_INLINE_VISIBILITY valarray&
976 operator*= (const _Expr& __v);
978 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
979 _LIBCPP_INLINE_VISIBILITY valarray&
980 operator/= (const _Expr& __v);
982 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
983 _LIBCPP_INLINE_VISIBILITY valarray&
984 operator%= (const _Expr& __v);
986 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
987 _LIBCPP_INLINE_VISIBILITY valarray&
988 operator+= (const _Expr& __v);
990 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
991 _LIBCPP_INLINE_VISIBILITY valarray&
992 operator-= (const _Expr& __v);
994 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
995 _LIBCPP_INLINE_VISIBILITY valarray&
996 operator^= (const _Expr& __v);
998 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
999 _LIBCPP_INLINE_VISIBILITY valarray&
1000 operator|= (const _Expr& __v);
1002 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1003 _LIBCPP_INLINE_VISIBILITY valarray&
1004 operator&= (const _Expr& __v);
1006 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1007 _LIBCPP_INLINE_VISIBILITY valarray&
1008 operator<<= (const _Expr& __v);
1010 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1011 _LIBCPP_INLINE_VISIBILITY valarray&
1012 operator>>= (const _Expr& __v);
1014 // member functions:
1015 _LIBCPP_INLINE_VISIBILITY
1016 void swap(valarray& __v) _NOEXCEPT;
1018 _LIBCPP_INLINE_VISIBILITY
1019 size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
1021 _LIBCPP_INLINE_VISIBILITY
1022 value_type sum() const;
1023 _LIBCPP_INLINE_VISIBILITY
1024 value_type min() const;
1025 _LIBCPP_INLINE_VISIBILITY
1026 value_type max() const;
1028 valarray shift (int __i) const;
1029 valarray cshift(int __i) const;
1030 valarray apply(value_type __f(value_type)) const;
1031 valarray apply(value_type __f(const value_type&)) const;
1032 void resize(size_t __n, value_type __x = value_type());
1035 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
1036 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
1037 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
1038 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
1039 template <class> friend class __mask_expr;
1040 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
1041 template <class> friend class __indirect_expr;
1042 template <class> friend class __val_expr;
1044 template <class _Up>
1047 begin(valarray<_Up>& __v);
1049 template <class _Up>
1052 begin(const valarray<_Up>& __v);
1054 template <class _Up>
1057 end(valarray<_Up>& __v);
1059 template <class _Up>
1062 end(const valarray<_Up>& __v);
1064 _LIBCPP_INLINE_VISIBILITY
1065 void __clear(size_t __capacity);
1066 valarray& __assign_range(const value_type* __f, const value_type* __l);
1069 #if _LIBCPP_STD_VER >= 17
1070 template<class _Tp, size_t _Size>
1071 valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>;
1074 extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t);
1076 template <class _Op, class _Tp>
1077 struct _UnaryOp<_Op, valarray<_Tp> >
1079 typedef typename _Op::__result_type __result_type;
1080 using value_type = __decay_t<__result_type>;
1083 const valarray<_Tp>& __a0_;
1085 _LIBCPP_INLINE_VISIBILITY
1086 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1088 _LIBCPP_INLINE_VISIBILITY
1089 __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1091 _LIBCPP_INLINE_VISIBILITY
1092 size_t size() const {return __a0_.size();}
1095 template <class _Op, class _Tp, class _A1>
1096 struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1098 typedef typename _Op::__result_type __result_type;
1099 using value_type = __decay_t<__result_type>;
1102 const valarray<_Tp>& __a0_;
1105 _LIBCPP_INLINE_VISIBILITY
1106 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1107 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1109 _LIBCPP_INLINE_VISIBILITY
1110 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1112 _LIBCPP_INLINE_VISIBILITY
1113 size_t size() const {return __a0_.size();}
1116 template <class _Op, class _A0, class _Tp>
1117 struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1119 typedef typename _Op::__result_type __result_type;
1120 using value_type = __decay_t<__result_type>;
1124 const valarray<_Tp>& __a1_;
1126 _LIBCPP_INLINE_VISIBILITY
1127 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1128 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1130 _LIBCPP_INLINE_VISIBILITY
1131 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1133 _LIBCPP_INLINE_VISIBILITY
1134 size_t size() const {return __a0_.size();}
1137 template <class _Op, class _Tp>
1138 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1140 typedef typename _Op::__result_type __result_type;
1141 using value_type = __decay_t<__result_type>;
1144 const valarray<_Tp>& __a0_;
1145 const valarray<_Tp>& __a1_;
1147 _LIBCPP_INLINE_VISIBILITY
1148 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1149 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1151 _LIBCPP_INLINE_VISIBILITY
1152 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1154 _LIBCPP_INLINE_VISIBILITY
1155 size_t size() const {return __a0_.size();}
1160 template <class _Tp>
1161 class _LIBCPP_TEMPLATE_VIS slice_array
1164 typedef _Tp value_type;
1172 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1174 _LIBCPP_INLINE_VISIBILITY
1175 operator=(const _Expr& __v) const;
1177 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1179 _LIBCPP_INLINE_VISIBILITY
1180 operator*=(const _Expr& __v) const;
1182 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1184 _LIBCPP_INLINE_VISIBILITY
1185 operator/=(const _Expr& __v) const;
1187 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1189 _LIBCPP_INLINE_VISIBILITY
1190 operator%=(const _Expr& __v) const;
1192 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1194 _LIBCPP_INLINE_VISIBILITY
1195 operator+=(const _Expr& __v) const;
1197 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1199 _LIBCPP_INLINE_VISIBILITY
1200 operator-=(const _Expr& __v) const;
1202 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1204 _LIBCPP_INLINE_VISIBILITY
1205 operator^=(const _Expr& __v) const;
1207 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1209 _LIBCPP_INLINE_VISIBILITY
1210 operator&=(const _Expr& __v) const;
1212 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1214 _LIBCPP_INLINE_VISIBILITY
1215 operator|=(const _Expr& __v) const;
1217 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1219 _LIBCPP_INLINE_VISIBILITY
1220 operator<<=(const _Expr& __v) const;
1222 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1224 _LIBCPP_INLINE_VISIBILITY
1225 operator>>=(const _Expr& __v) const;
1227 slice_array(slice_array const&) = default;
1229 _LIBCPP_INLINE_VISIBILITY
1230 const slice_array& operator=(const slice_array& __sa) const;
1232 _LIBCPP_INLINE_VISIBILITY
1233 void operator=(const value_type& __x) const;
1235 _LIBCPP_INLINE_VISIBILITY
1236 void operator=(const valarray<value_type>& __va) const;
1239 _LIBCPP_INLINE_VISIBILITY
1240 slice_array(const slice& __sl, const valarray<value_type>& __v)
1241 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1242 __size_(__sl.size()),
1243 __stride_(__sl.stride())
1246 template <class> friend class valarray;
1249 template <class _Tp>
1251 const slice_array<_Tp>&
1252 slice_array<_Tp>::operator=(const slice_array& __sa) const
1254 value_type* __t = __vp_;
1255 const value_type* __s = __sa.__vp_;
1256 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1261 template <class _Tp>
1262 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1265 slice_array<_Tp>::operator=(const _Expr& __v) const
1267 value_type* __t = __vp_;
1268 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1272 template <class _Tp>
1274 slice_array<_Tp>::operator=(const valarray<value_type>& __va) const
1276 value_type* __t = __vp_;
1277 for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)
1281 template <class _Tp>
1282 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1285 slice_array<_Tp>::operator*=(const _Expr& __v) const
1287 value_type* __t = __vp_;
1288 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1292 template <class _Tp>
1293 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1296 slice_array<_Tp>::operator/=(const _Expr& __v) const
1298 value_type* __t = __vp_;
1299 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1303 template <class _Tp>
1304 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1307 slice_array<_Tp>::operator%=(const _Expr& __v) const
1309 value_type* __t = __vp_;
1310 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1314 template <class _Tp>
1315 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1318 slice_array<_Tp>::operator+=(const _Expr& __v) const
1320 value_type* __t = __vp_;
1321 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1325 template <class _Tp>
1326 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1329 slice_array<_Tp>::operator-=(const _Expr& __v) const
1331 value_type* __t = __vp_;
1332 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1336 template <class _Tp>
1337 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1340 slice_array<_Tp>::operator^=(const _Expr& __v) const
1342 value_type* __t = __vp_;
1343 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1347 template <class _Tp>
1348 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1351 slice_array<_Tp>::operator&=(const _Expr& __v) const
1353 value_type* __t = __vp_;
1354 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1358 template <class _Tp>
1359 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1362 slice_array<_Tp>::operator|=(const _Expr& __v) const
1364 value_type* __t = __vp_;
1365 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1369 template <class _Tp>
1370 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1373 slice_array<_Tp>::operator<<=(const _Expr& __v) const
1375 value_type* __t = __vp_;
1376 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1380 template <class _Tp>
1381 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1384 slice_array<_Tp>::operator>>=(const _Expr& __v) const
1386 value_type* __t = __vp_;
1387 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1391 template <class _Tp>
1394 slice_array<_Tp>::operator=(const value_type& __x) const
1396 value_type* __t = __vp_;
1397 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1403 class _LIBCPP_EXPORTED_FROM_ABI gslice
1405 valarray<size_t> __size_;
1406 valarray<size_t> __stride_;
1407 valarray<size_t> __1d_;
1410 _LIBCPP_INLINE_VISIBILITY
1413 _LIBCPP_INLINE_VISIBILITY
1414 gslice(size_t __start, const valarray<size_t>& __size,
1415 const valarray<size_t>& __stride)
1420 #ifndef _LIBCPP_CXX03_LANG
1422 _LIBCPP_INLINE_VISIBILITY
1423 gslice(size_t __start, const valarray<size_t>& __size,
1424 valarray<size_t>&& __stride)
1426 __stride_(std::move(__stride))
1429 _LIBCPP_INLINE_VISIBILITY
1430 gslice(size_t __start, valarray<size_t>&& __size,
1431 const valarray<size_t>& __stride)
1432 : __size_(std::move(__size)),
1436 _LIBCPP_INLINE_VISIBILITY
1437 gslice(size_t __start, valarray<size_t>&& __size,
1438 valarray<size_t>&& __stride)
1439 : __size_(std::move(__size)),
1440 __stride_(std::move(__stride))
1443 #endif // _LIBCPP_CXX03_LANG
1445 _LIBCPP_INLINE_VISIBILITY
1446 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1448 _LIBCPP_INLINE_VISIBILITY
1449 valarray<size_t> size() const {return __size_;}
1451 _LIBCPP_INLINE_VISIBILITY
1452 valarray<size_t> stride() const {return __stride_;}
1455 void __init(size_t __start);
1457 template <class> friend class gslice_array;
1458 template <class> friend class valarray;
1459 template <class> friend class __val_expr;
1464 template <class _Tp>
1465 class _LIBCPP_TEMPLATE_VIS gslice_array
1468 typedef _Tp value_type;
1472 valarray<size_t> __1d_;
1475 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1477 _LIBCPP_INLINE_VISIBILITY
1478 operator=(const _Expr& __v) const;
1480 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1482 _LIBCPP_INLINE_VISIBILITY
1483 operator*=(const _Expr& __v) const;
1485 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1487 _LIBCPP_INLINE_VISIBILITY
1488 operator/=(const _Expr& __v) const;
1490 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1492 _LIBCPP_INLINE_VISIBILITY
1493 operator%=(const _Expr& __v) const;
1495 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1497 _LIBCPP_INLINE_VISIBILITY
1498 operator+=(const _Expr& __v) const;
1500 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1502 _LIBCPP_INLINE_VISIBILITY
1503 operator-=(const _Expr& __v) const;
1505 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1507 _LIBCPP_INLINE_VISIBILITY
1508 operator^=(const _Expr& __v) const;
1510 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1512 _LIBCPP_INLINE_VISIBILITY
1513 operator&=(const _Expr& __v) const;
1515 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1517 _LIBCPP_INLINE_VISIBILITY
1518 operator|=(const _Expr& __v) const;
1520 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1522 _LIBCPP_INLINE_VISIBILITY
1523 operator<<=(const _Expr& __v) const;
1525 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1527 _LIBCPP_INLINE_VISIBILITY
1528 operator>>=(const _Expr& __v) const;
1530 _LIBCPP_INLINE_VISIBILITY
1531 const gslice_array& operator=(const gslice_array& __ga) const;
1533 _LIBCPP_INLINE_VISIBILITY
1534 void operator=(const value_type& __x) const;
1536 gslice_array(const gslice_array&) = default;
1539 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1540 : __vp_(const_cast<value_type*>(__v.__begin_)),
1544 #ifndef _LIBCPP_CXX03_LANG
1545 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1546 : __vp_(const_cast<value_type*>(__v.__begin_)),
1547 __1d_(std::move(__gs.__1d_))
1549 #endif // _LIBCPP_CXX03_LANG
1551 template <class> friend class valarray;
1554 template <class _Tp>
1555 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1558 gslice_array<_Tp>::operator=(const _Expr& __v) const
1560 typedef const size_t* _Ip;
1562 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1563 __vp_[*__i] = __v[__j];
1566 template <class _Tp>
1567 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1570 gslice_array<_Tp>::operator*=(const _Expr& __v) const
1572 typedef const size_t* _Ip;
1574 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1575 __vp_[*__i] *= __v[__j];
1578 template <class _Tp>
1579 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1582 gslice_array<_Tp>::operator/=(const _Expr& __v) const
1584 typedef const size_t* _Ip;
1586 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1587 __vp_[*__i] /= __v[__j];
1590 template <class _Tp>
1591 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1594 gslice_array<_Tp>::operator%=(const _Expr& __v) const
1596 typedef const size_t* _Ip;
1598 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1599 __vp_[*__i] %= __v[__j];
1602 template <class _Tp>
1603 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1606 gslice_array<_Tp>::operator+=(const _Expr& __v) const
1608 typedef const size_t* _Ip;
1610 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1611 __vp_[*__i] += __v[__j];
1614 template <class _Tp>
1615 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1618 gslice_array<_Tp>::operator-=(const _Expr& __v) const
1620 typedef const size_t* _Ip;
1622 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1623 __vp_[*__i] -= __v[__j];
1626 template <class _Tp>
1627 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1630 gslice_array<_Tp>::operator^=(const _Expr& __v) const
1632 typedef const size_t* _Ip;
1634 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1635 __vp_[*__i] ^= __v[__j];
1638 template <class _Tp>
1639 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1642 gslice_array<_Tp>::operator&=(const _Expr& __v) const
1644 typedef const size_t* _Ip;
1646 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1647 __vp_[*__i] &= __v[__j];
1650 template <class _Tp>
1651 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1654 gslice_array<_Tp>::operator|=(const _Expr& __v) const
1656 typedef const size_t* _Ip;
1658 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1659 __vp_[*__i] |= __v[__j];
1662 template <class _Tp>
1663 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1666 gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1668 typedef const size_t* _Ip;
1670 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1671 __vp_[*__i] <<= __v[__j];
1674 template <class _Tp>
1675 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1678 gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1680 typedef const size_t* _Ip;
1682 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1683 __vp_[*__i] >>= __v[__j];
1686 template <class _Tp>
1688 const gslice_array<_Tp>&
1689 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1691 typedef const size_t* _Ip;
1692 const value_type* __s = __ga.__vp_;
1693 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1694 __i != __e; ++__i, ++__j)
1695 __vp_[*__i] = __s[*__j];
1699 template <class _Tp>
1702 gslice_array<_Tp>::operator=(const value_type& __x) const
1704 typedef const size_t* _Ip;
1705 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1711 template <class _Tp>
1712 class _LIBCPP_TEMPLATE_VIS mask_array
1715 typedef _Tp value_type;
1719 valarray<size_t> __1d_;
1722 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1724 _LIBCPP_INLINE_VISIBILITY
1725 operator=(const _Expr& __v) const;
1727 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1729 _LIBCPP_INLINE_VISIBILITY
1730 operator*=(const _Expr& __v) const;
1732 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1734 _LIBCPP_INLINE_VISIBILITY
1735 operator/=(const _Expr& __v) const;
1737 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1739 _LIBCPP_INLINE_VISIBILITY
1740 operator%=(const _Expr& __v) const;
1742 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1744 _LIBCPP_INLINE_VISIBILITY
1745 operator+=(const _Expr& __v) const;
1747 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1749 _LIBCPP_INLINE_VISIBILITY
1750 operator-=(const _Expr& __v) const;
1752 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1754 _LIBCPP_INLINE_VISIBILITY
1755 operator^=(const _Expr& __v) const;
1757 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1759 _LIBCPP_INLINE_VISIBILITY
1760 operator&=(const _Expr& __v) const;
1762 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1764 _LIBCPP_INLINE_VISIBILITY
1765 operator|=(const _Expr& __v) const;
1767 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1769 _LIBCPP_INLINE_VISIBILITY
1770 operator<<=(const _Expr& __v) const;
1772 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1774 _LIBCPP_INLINE_VISIBILITY
1775 operator>>=(const _Expr& __v) const;
1777 mask_array(const mask_array&) = default;
1779 _LIBCPP_INLINE_VISIBILITY
1780 const mask_array& operator=(const mask_array& __ma) const;
1782 _LIBCPP_INLINE_VISIBILITY
1783 void operator=(const value_type& __x) const;
1786 _LIBCPP_INLINE_VISIBILITY
1787 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1788 : __vp_(const_cast<value_type*>(__v.__begin_)),
1789 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
1792 for (size_t __i = 0; __i < __vb.size(); ++__i)
1797 template <class> friend class valarray;
1800 template <class _Tp>
1801 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1804 mask_array<_Tp>::operator=(const _Expr& __v) const
1806 size_t __n = __1d_.size();
1807 for (size_t __i = 0; __i < __n; ++__i)
1808 __vp_[__1d_[__i]] = __v[__i];
1811 template <class _Tp>
1812 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1815 mask_array<_Tp>::operator*=(const _Expr& __v) const
1817 size_t __n = __1d_.size();
1818 for (size_t __i = 0; __i < __n; ++__i)
1819 __vp_[__1d_[__i]] *= __v[__i];
1822 template <class _Tp>
1823 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1826 mask_array<_Tp>::operator/=(const _Expr& __v) const
1828 size_t __n = __1d_.size();
1829 for (size_t __i = 0; __i < __n; ++__i)
1830 __vp_[__1d_[__i]] /= __v[__i];
1833 template <class _Tp>
1834 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1837 mask_array<_Tp>::operator%=(const _Expr& __v) const
1839 size_t __n = __1d_.size();
1840 for (size_t __i = 0; __i < __n; ++__i)
1841 __vp_[__1d_[__i]] %= __v[__i];
1844 template <class _Tp>
1845 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1848 mask_array<_Tp>::operator+=(const _Expr& __v) const
1850 size_t __n = __1d_.size();
1851 for (size_t __i = 0; __i < __n; ++__i)
1852 __vp_[__1d_[__i]] += __v[__i];
1855 template <class _Tp>
1856 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1859 mask_array<_Tp>::operator-=(const _Expr& __v) const
1861 size_t __n = __1d_.size();
1862 for (size_t __i = 0; __i < __n; ++__i)
1863 __vp_[__1d_[__i]] -= __v[__i];
1866 template <class _Tp>
1867 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1870 mask_array<_Tp>::operator^=(const _Expr& __v) const
1872 size_t __n = __1d_.size();
1873 for (size_t __i = 0; __i < __n; ++__i)
1874 __vp_[__1d_[__i]] ^= __v[__i];
1877 template <class _Tp>
1878 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1881 mask_array<_Tp>::operator&=(const _Expr& __v) const
1883 size_t __n = __1d_.size();
1884 for (size_t __i = 0; __i < __n; ++__i)
1885 __vp_[__1d_[__i]] &= __v[__i];
1888 template <class _Tp>
1889 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1892 mask_array<_Tp>::operator|=(const _Expr& __v) const
1894 size_t __n = __1d_.size();
1895 for (size_t __i = 0; __i < __n; ++__i)
1896 __vp_[__1d_[__i]] |= __v[__i];
1899 template <class _Tp>
1900 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1903 mask_array<_Tp>::operator<<=(const _Expr& __v) const
1905 size_t __n = __1d_.size();
1906 for (size_t __i = 0; __i < __n; ++__i)
1907 __vp_[__1d_[__i]] <<= __v[__i];
1910 template <class _Tp>
1911 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1914 mask_array<_Tp>::operator>>=(const _Expr& __v) const
1916 size_t __n = __1d_.size();
1917 for (size_t __i = 0; __i < __n; ++__i)
1918 __vp_[__1d_[__i]] >>= __v[__i];
1921 template <class _Tp>
1923 const mask_array<_Tp>&
1924 mask_array<_Tp>::operator=(const mask_array& __ma) const
1926 size_t __n = __1d_.size();
1927 for (size_t __i = 0; __i < __n; ++__i)
1928 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
1932 template <class _Tp>
1935 mask_array<_Tp>::operator=(const value_type& __x) const
1937 size_t __n = __1d_.size();
1938 for (size_t __i = 0; __i < __n; ++__i)
1939 __vp_[__1d_[__i]] = __x;
1942 template <class _ValExpr>
1945 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
1947 typedef typename _RmExpr::value_type value_type;
1948 typedef value_type __result_type;
1952 valarray<size_t> __1d_;
1954 _LIBCPP_INLINE_VISIBILITY
1955 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
1957 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
1960 for (size_t __i = 0; __i < __vb.size(); ++__i)
1966 _LIBCPP_INLINE_VISIBILITY
1967 __result_type operator[](size_t __i) const
1968 {return __expr_[__1d_[__i]];}
1970 _LIBCPP_INLINE_VISIBILITY
1971 size_t size() const {return __1d_.size();}
1973 template <class> friend class __val_expr;
1974 template <class> friend class valarray;
1979 template <class _Tp>
1980 class _LIBCPP_TEMPLATE_VIS indirect_array
1983 typedef _Tp value_type;
1987 valarray<size_t> __1d_;
1990 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1992 _LIBCPP_INLINE_VISIBILITY
1993 operator=(const _Expr& __v) const;
1995 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1997 _LIBCPP_INLINE_VISIBILITY
1998 operator*=(const _Expr& __v) const;
2000 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2002 _LIBCPP_INLINE_VISIBILITY
2003 operator/=(const _Expr& __v) const;
2005 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2007 _LIBCPP_INLINE_VISIBILITY
2008 operator%=(const _Expr& __v) const;
2010 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2012 _LIBCPP_INLINE_VISIBILITY
2013 operator+=(const _Expr& __v) const;
2015 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2017 _LIBCPP_INLINE_VISIBILITY
2018 operator-=(const _Expr& __v) const;
2020 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2022 _LIBCPP_INLINE_VISIBILITY
2023 operator^=(const _Expr& __v) const;
2025 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2027 _LIBCPP_INLINE_VISIBILITY
2028 operator&=(const _Expr& __v) const;
2030 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2032 _LIBCPP_INLINE_VISIBILITY
2033 operator|=(const _Expr& __v) const;
2035 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2037 _LIBCPP_INLINE_VISIBILITY
2038 operator<<=(const _Expr& __v) const;
2040 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2042 _LIBCPP_INLINE_VISIBILITY
2043 operator>>=(const _Expr& __v) const;
2045 indirect_array(const indirect_array&) = default;
2047 _LIBCPP_INLINE_VISIBILITY
2048 const indirect_array& operator=(const indirect_array& __ia) const;
2050 _LIBCPP_INLINE_VISIBILITY
2051 void operator=(const value_type& __x) const;
2054 _LIBCPP_INLINE_VISIBILITY
2055 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2056 : __vp_(const_cast<value_type*>(__v.__begin_)),
2060 #ifndef _LIBCPP_CXX03_LANG
2062 _LIBCPP_INLINE_VISIBILITY
2063 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2064 : __vp_(const_cast<value_type*>(__v.__begin_)),
2065 __1d_(std::move(__ia))
2068 #endif // _LIBCPP_CXX03_LANG
2070 template <class> friend class valarray;
2073 template <class _Tp>
2074 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2077 indirect_array<_Tp>::operator=(const _Expr& __v) const
2079 size_t __n = __1d_.size();
2080 for (size_t __i = 0; __i < __n; ++__i)
2081 __vp_[__1d_[__i]] = __v[__i];
2084 template <class _Tp>
2085 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2088 indirect_array<_Tp>::operator*=(const _Expr& __v) const
2090 size_t __n = __1d_.size();
2091 for (size_t __i = 0; __i < __n; ++__i)
2092 __vp_[__1d_[__i]] *= __v[__i];
2095 template <class _Tp>
2096 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2099 indirect_array<_Tp>::operator/=(const _Expr& __v) const
2101 size_t __n = __1d_.size();
2102 for (size_t __i = 0; __i < __n; ++__i)
2103 __vp_[__1d_[__i]] /= __v[__i];
2106 template <class _Tp>
2107 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2110 indirect_array<_Tp>::operator%=(const _Expr& __v) const
2112 size_t __n = __1d_.size();
2113 for (size_t __i = 0; __i < __n; ++__i)
2114 __vp_[__1d_[__i]] %= __v[__i];
2117 template <class _Tp>
2118 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2121 indirect_array<_Tp>::operator+=(const _Expr& __v) const
2123 size_t __n = __1d_.size();
2124 for (size_t __i = 0; __i < __n; ++__i)
2125 __vp_[__1d_[__i]] += __v[__i];
2128 template <class _Tp>
2129 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2132 indirect_array<_Tp>::operator-=(const _Expr& __v) const
2134 size_t __n = __1d_.size();
2135 for (size_t __i = 0; __i < __n; ++__i)
2136 __vp_[__1d_[__i]] -= __v[__i];
2139 template <class _Tp>
2140 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2143 indirect_array<_Tp>::operator^=(const _Expr& __v) const
2145 size_t __n = __1d_.size();
2146 for (size_t __i = 0; __i < __n; ++__i)
2147 __vp_[__1d_[__i]] ^= __v[__i];
2150 template <class _Tp>
2151 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2154 indirect_array<_Tp>::operator&=(const _Expr& __v) const
2156 size_t __n = __1d_.size();
2157 for (size_t __i = 0; __i < __n; ++__i)
2158 __vp_[__1d_[__i]] &= __v[__i];
2161 template <class _Tp>
2162 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2165 indirect_array<_Tp>::operator|=(const _Expr& __v) const
2167 size_t __n = __1d_.size();
2168 for (size_t __i = 0; __i < __n; ++__i)
2169 __vp_[__1d_[__i]] |= __v[__i];
2172 template <class _Tp>
2173 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2176 indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2178 size_t __n = __1d_.size();
2179 for (size_t __i = 0; __i < __n; ++__i)
2180 __vp_[__1d_[__i]] <<= __v[__i];
2183 template <class _Tp>
2184 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2187 indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2189 size_t __n = __1d_.size();
2190 for (size_t __i = 0; __i < __n; ++__i)
2191 __vp_[__1d_[__i]] >>= __v[__i];
2194 template <class _Tp>
2196 const indirect_array<_Tp>&
2197 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2199 typedef const size_t* _Ip;
2200 const value_type* __s = __ia.__vp_;
2201 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2202 __i != __e; ++__i, ++__j)
2203 __vp_[*__i] = __s[*__j];
2207 template <class _Tp>
2210 indirect_array<_Tp>::operator=(const value_type& __x) const
2212 typedef const size_t* _Ip;
2213 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2217 template <class _ValExpr>
2218 class __indirect_expr
2220 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
2222 typedef typename _RmExpr::value_type value_type;
2223 typedef value_type __result_type;
2227 valarray<size_t> __1d_;
2229 _LIBCPP_INLINE_VISIBILITY
2230 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2235 #ifndef _LIBCPP_CXX03_LANG
2237 _LIBCPP_INLINE_VISIBILITY
2238 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2240 __1d_(std::move(__ia))
2243 #endif // _LIBCPP_CXX03_LANG
2246 _LIBCPP_INLINE_VISIBILITY
2247 __result_type operator[](size_t __i) const
2248 {return __expr_[__1d_[__i]];}
2250 _LIBCPP_INLINE_VISIBILITY
2251 size_t size() const {return __1d_.size();}
2253 template <class> friend class __val_expr;
2254 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
2257 template<class _ValExpr>
2260 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
2264 typedef typename _RmExpr::value_type value_type;
2265 typedef typename _RmExpr::__result_type __result_type;
2267 _LIBCPP_INLINE_VISIBILITY
2268 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2270 _LIBCPP_INLINE_VISIBILITY
2271 __result_type operator[](size_t __i) const
2272 {return __expr_[__i];}
2274 _LIBCPP_INLINE_VISIBILITY
2275 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2277 typedef __slice_expr<_ValExpr> _NewExpr;
2278 return __val_expr< _NewExpr >(_NewExpr(__s, __expr_));
2281 _LIBCPP_INLINE_VISIBILITY
2282 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2284 typedef __indirect_expr<_ValExpr> _NewExpr;
2285 return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_));
2288 _LIBCPP_INLINE_VISIBILITY
2289 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2291 typedef __mask_expr<_ValExpr> _NewExpr;
2292 return __val_expr< _NewExpr >( _NewExpr(__vb, __expr_));
2295 _LIBCPP_INLINE_VISIBILITY
2296 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2298 typedef __indirect_expr<_ValExpr> _NewExpr;
2299 return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_));
2302 _LIBCPP_INLINE_VISIBILITY
2303 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2306 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2307 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2310 _LIBCPP_INLINE_VISIBILITY
2311 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2314 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2315 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2318 _LIBCPP_INLINE_VISIBILITY
2319 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2322 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2323 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2326 _LIBCPP_INLINE_VISIBILITY
2327 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2330 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2331 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2334 operator valarray<__result_type>() const;
2336 _LIBCPP_INLINE_VISIBILITY
2337 size_t size() const {return __expr_.size();}
2339 _LIBCPP_INLINE_VISIBILITY
2340 __result_type sum() const
2342 size_t __n = __expr_.size();
2343 __result_type __r = __n ? __expr_[0] : __result_type();
2344 for (size_t __i = 1; __i < __n; ++__i)
2345 __r += __expr_[__i];
2349 _LIBCPP_INLINE_VISIBILITY
2350 __result_type min() const
2352 size_t __n = size();
2353 __result_type __r = __n ? (*this)[0] : __result_type();
2354 for (size_t __i = 1; __i < __n; ++__i)
2356 __result_type __x = __expr_[__i];
2363 _LIBCPP_INLINE_VISIBILITY
2364 __result_type max() const
2366 size_t __n = size();
2367 __result_type __r = __n ? (*this)[0] : __result_type();
2368 for (size_t __i = 1; __i < __n; ++__i)
2370 __result_type __x = __expr_[__i];
2377 _LIBCPP_INLINE_VISIBILITY
2378 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2379 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2381 _LIBCPP_INLINE_VISIBILITY
2382 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2383 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2385 _LIBCPP_INLINE_VISIBILITY
2386 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2387 apply(value_type __f(value_type)) const
2389 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2390 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2391 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2394 _LIBCPP_INLINE_VISIBILITY
2395 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2396 apply(value_type __f(const value_type&)) const
2398 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2399 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2400 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2404 template<class _ValExpr>
2405 __val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const
2407 valarray<__result_type> __r;
2408 size_t __n = __expr_.size();
2412 __r.__end_ = allocator<__result_type>().allocate(__n);
2413 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2414 ::new ((void*)__r.__end_) __result_type(__expr_[__i]);
2421 template <class _Tp>
2423 valarray<_Tp>::valarray(size_t __n)
2424 : __begin_(nullptr),
2429 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2430 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2433 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2434 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
2435 ::new ((void*)__end_) value_type();
2436 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2443 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2447 template <class _Tp>
2449 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2450 : __begin_(nullptr),
2456 template <class _Tp>
2457 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2458 : __begin_(nullptr),
2463 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2464 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2467 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2468 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
2469 ::new ((void*)__end_) value_type(*__p);
2470 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2477 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2481 template <class _Tp>
2482 valarray<_Tp>::valarray(const valarray& __v)
2483 : __begin_(nullptr),
2488 __begin_ = __end_ = allocator<value_type>().allocate(__v.size());
2489 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2492 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2493 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2494 ::new ((void*)__end_) value_type(*__p);
2495 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2499 __clear(__v.size());
2502 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2506 #ifndef _LIBCPP_CXX03_LANG
2508 template <class _Tp>
2510 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
2511 : __begin_(__v.__begin_),
2514 __v.__begin_ = __v.__end_ = nullptr;
2517 template <class _Tp>
2518 valarray<_Tp>::valarray(initializer_list<value_type> __il)
2519 : __begin_(nullptr),
2522 const size_t __n = __il.size();
2525 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2526 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2529 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2530 size_t __n_left = __n;
2531 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
2532 ::new ((void*)__end_) value_type(*__p);
2533 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2540 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2544 #endif // _LIBCPP_CXX03_LANG
2546 template <class _Tp>
2547 valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2548 : __begin_(nullptr),
2551 const size_t __n = __sa.__size_;
2554 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2555 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2558 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2559 size_t __n_left = __n;
2560 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
2561 ::new ((void*)__end_) value_type(*__p);
2562 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2569 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2573 template <class _Tp>
2574 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2575 : __begin_(nullptr),
2578 const size_t __n = __ga.__1d_.size();
2581 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2582 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2585 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2586 typedef const size_t* _Ip;
2587 const value_type* __s = __ga.__vp_;
2588 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2589 __i != __e; ++__i, ++__end_)
2590 ::new ((void*)__end_) value_type(__s[*__i]);
2591 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2598 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2602 template <class _Tp>
2603 valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2604 : __begin_(nullptr),
2607 const size_t __n = __ma.__1d_.size();
2610 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2611 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2614 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2615 typedef const size_t* _Ip;
2616 const value_type* __s = __ma.__vp_;
2617 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2618 __i != __e; ++__i, ++__end_)
2619 ::new ((void*)__end_) value_type(__s[*__i]);
2620 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2627 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2631 template <class _Tp>
2632 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2633 : __begin_(nullptr),
2636 const size_t __n = __ia.__1d_.size();
2639 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2640 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2643 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2644 typedef const size_t* _Ip;
2645 const value_type* __s = __ia.__vp_;
2646 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2647 __i != __e; ++__i, ++__end_)
2648 ::new ((void*)__end_) value_type(__s[*__i]);
2649 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2656 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2660 template <class _Tp>
2662 valarray<_Tp>::~valarray()
2667 template <class _Tp>
2669 valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l)
2671 size_t __n = __l - __f;
2675 __begin_ = allocator<value_type>().allocate(__n);
2676 __end_ = __begin_ + __n;
2677 _VSTD::uninitialized_copy(__f, __l, __begin_);
2679 _VSTD::copy(__f, __l, __begin_);
2684 template <class _Tp>
2686 valarray<_Tp>::operator=(const valarray& __v)
2688 if (this != _VSTD::addressof(__v))
2689 return __assign_range(__v.__begin_, __v.__end_);
2693 #ifndef _LIBCPP_CXX03_LANG
2695 template <class _Tp>
2698 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
2701 __begin_ = __v.__begin_;
2702 __end_ = __v.__end_;
2703 __v.__begin_ = nullptr;
2704 __v.__end_ = nullptr;
2708 template <class _Tp>
2711 valarray<_Tp>::operator=(initializer_list<value_type> __il)
2713 return __assign_range(__il.begin(), __il.end());
2716 #endif // _LIBCPP_CXX03_LANG
2718 template <class _Tp>
2721 valarray<_Tp>::operator=(const value_type& __x)
2723 _VSTD::fill(__begin_, __end_, __x);
2727 template <class _Tp>
2730 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
2732 value_type* __t = __begin_;
2733 const value_type* __s = __sa.__vp_;
2734 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
2739 template <class _Tp>
2742 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
2744 typedef const size_t* _Ip;
2745 value_type* __t = __begin_;
2746 const value_type* __s = __ga.__vp_;
2747 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2748 __i != __e; ++__i, ++__t)
2753 template <class _Tp>
2756 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
2758 typedef const size_t* _Ip;
2759 value_type* __t = __begin_;
2760 const value_type* __s = __ma.__vp_;
2761 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2762 __i != __e; ++__i, ++__t)
2767 template <class _Tp>
2770 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
2772 typedef const size_t* _Ip;
2773 value_type* __t = __begin_;
2774 const value_type* __s = __ia.__vp_;
2775 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2776 __i != __e; ++__i, ++__t)
2781 template <class _Tp>
2782 template <class _ValExpr>
2785 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
2787 size_t __n = __v.size();
2790 value_type* __t = __begin_;
2791 for (size_t __i = 0; __i != __n; ++__t, ++__i)
2792 *__t = __result_type(__v[__i]);
2796 template <class _Tp>
2798 __val_expr<__slice_expr<const valarray<_Tp>&> >
2799 valarray<_Tp>::operator[](slice __s) const
2801 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
2804 template <class _Tp>
2807 valarray<_Tp>::operator[](slice __s)
2809 return slice_array<value_type>(__s, *this);
2812 template <class _Tp>
2814 __val_expr<__indirect_expr<const valarray<_Tp>&> >
2815 valarray<_Tp>::operator[](const gslice& __gs) const
2817 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
2820 template <class _Tp>
2823 valarray<_Tp>::operator[](const gslice& __gs)
2825 return gslice_array<value_type>(__gs, *this);
2828 #ifndef _LIBCPP_CXX03_LANG
2830 template <class _Tp>
2832 __val_expr<__indirect_expr<const valarray<_Tp>&> >
2833 valarray<_Tp>::operator[](gslice&& __gs) const
2835 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this));
2838 template <class _Tp>
2841 valarray<_Tp>::operator[](gslice&& __gs)
2843 return gslice_array<value_type>(std::move(__gs), *this);
2846 #endif // _LIBCPP_CXX03_LANG
2848 template <class _Tp>
2850 __val_expr<__mask_expr<const valarray<_Tp>&> >
2851 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
2853 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
2856 template <class _Tp>
2859 valarray<_Tp>::operator[](const valarray<bool>& __vb)
2861 return mask_array<value_type>(__vb, *this);
2864 #ifndef _LIBCPP_CXX03_LANG
2866 template <class _Tp>
2868 __val_expr<__mask_expr<const valarray<_Tp>&> >
2869 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
2871 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this));
2874 template <class _Tp>
2877 valarray<_Tp>::operator[](valarray<bool>&& __vb)
2879 return mask_array<value_type>(std::move(__vb), *this);
2882 #endif // _LIBCPP_CXX03_LANG
2884 template <class _Tp>
2886 __val_expr<__indirect_expr<const valarray<_Tp>&> >
2887 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
2889 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
2892 template <class _Tp>
2895 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
2897 return indirect_array<value_type>(__vs, *this);
2900 #ifndef _LIBCPP_CXX03_LANG
2902 template <class _Tp>
2904 __val_expr<__indirect_expr<const valarray<_Tp>&> >
2905 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
2907 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this));
2910 template <class _Tp>
2913 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
2915 return indirect_array<value_type>(std::move(__vs), *this);
2918 #endif // _LIBCPP_CXX03_LANG
2920 template <class _Tp>
2922 __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> >
2923 valarray<_Tp>::operator+() const
2925 using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>;
2926 return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this));
2929 template <class _Tp>
2931 __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> >
2932 valarray<_Tp>::operator-() const
2934 using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>;
2935 return __val_expr<_Op>(_Op(negate<_Tp>(), *this));
2938 template <class _Tp>
2940 __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> >
2941 valarray<_Tp>::operator~() const
2943 using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>;
2944 return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this));
2947 template <class _Tp>
2949 __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> >
2950 valarray<_Tp>::operator!() const
2952 using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>;
2953 return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this));
2956 template <class _Tp>
2959 valarray<_Tp>::operator*=(const value_type& __x)
2961 for (value_type* __p = __begin_; __p != __end_; ++__p)
2966 template <class _Tp>
2969 valarray<_Tp>::operator/=(const value_type& __x)
2971 for (value_type* __p = __begin_; __p != __end_; ++__p)
2976 template <class _Tp>
2979 valarray<_Tp>::operator%=(const value_type& __x)
2981 for (value_type* __p = __begin_; __p != __end_; ++__p)
2986 template <class _Tp>
2989 valarray<_Tp>::operator+=(const value_type& __x)
2991 for (value_type* __p = __begin_; __p != __end_; ++__p)
2996 template <class _Tp>
2999 valarray<_Tp>::operator-=(const value_type& __x)
3001 for (value_type* __p = __begin_; __p != __end_; ++__p)
3006 template <class _Tp>
3009 valarray<_Tp>::operator^=(const value_type& __x)
3011 for (value_type* __p = __begin_; __p != __end_; ++__p)
3016 template <class _Tp>
3019 valarray<_Tp>::operator&=(const value_type& __x)
3021 for (value_type* __p = __begin_; __p != __end_; ++__p)
3026 template <class _Tp>
3029 valarray<_Tp>::operator|=(const value_type& __x)
3031 for (value_type* __p = __begin_; __p != __end_; ++__p)
3036 template <class _Tp>
3039 valarray<_Tp>::operator<<=(const value_type& __x)
3041 for (value_type* __p = __begin_; __p != __end_; ++__p)
3046 template <class _Tp>
3049 valarray<_Tp>::operator>>=(const value_type& __x)
3051 for (value_type* __p = __begin_; __p != __end_; ++__p)
3056 template <class _Tp>
3057 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3060 valarray<_Tp>::operator*=(const _Expr& __v)
3063 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3068 template <class _Tp>
3069 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3072 valarray<_Tp>::operator/=(const _Expr& __v)
3075 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3080 template <class _Tp>
3081 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3084 valarray<_Tp>::operator%=(const _Expr& __v)
3087 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3092 template <class _Tp>
3093 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3096 valarray<_Tp>::operator+=(const _Expr& __v)
3099 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3104 template <class _Tp>
3105 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3108 valarray<_Tp>::operator-=(const _Expr& __v)
3111 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3116 template <class _Tp>
3117 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3120 valarray<_Tp>::operator^=(const _Expr& __v)
3123 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3128 template <class _Tp>
3129 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3132 valarray<_Tp>::operator|=(const _Expr& __v)
3135 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3140 template <class _Tp>
3141 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3144 valarray<_Tp>::operator&=(const _Expr& __v)
3147 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3152 template <class _Tp>
3153 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3156 valarray<_Tp>::operator<<=(const _Expr& __v)
3159 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3164 template <class _Tp>
3165 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
3168 valarray<_Tp>::operator>>=(const _Expr& __v)
3171 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3176 template <class _Tp>
3179 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
3181 _VSTD::swap(__begin_, __v.__begin_);
3182 _VSTD::swap(__end_, __v.__end_);
3185 template <class _Tp>
3188 valarray<_Tp>::sum() const
3190 if (__begin_ == __end_)
3191 return value_type();
3192 const value_type* __p = __begin_;
3194 for (++__p; __p != __end_; ++__p)
3199 template <class _Tp>
3202 valarray<_Tp>::min() const
3204 if (__begin_ == __end_)
3205 return value_type();
3206 return *_VSTD::min_element(__begin_, __end_);
3209 template <class _Tp>
3212 valarray<_Tp>::max() const
3214 if (__begin_ == __end_)
3215 return value_type();
3216 return *_VSTD::max_element(__begin_, __end_);
3219 template <class _Tp>
3221 valarray<_Tp>::shift(int __i) const
3223 valarray<value_type> __r;
3224 size_t __n = size();
3227 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3228 const value_type* __sb;
3233 __i = _VSTD::min(__i, static_cast<int>(__n));
3234 __sb = __begin_ + __i;
3235 __tb = __r.__begin_;
3236 __te = __r.__begin_ + (__n - __i);
3240 __i = _VSTD::min(-__i, static_cast<int>(__n));
3242 __tb = __r.__begin_ + __i;
3243 __te = __r.__begin_ + __n;
3245 for (; __r.__end_ != __tb; ++__r.__end_)
3246 ::new ((void*)__r.__end_) value_type();
3247 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3248 ::new ((void*)__r.__end_) value_type(*__sb);
3249 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3250 ::new ((void*)__r.__end_) value_type();
3255 template <class _Tp>
3257 valarray<_Tp>::cshift(int __i) const
3259 valarray<value_type> __r;
3260 size_t __n = size();
3263 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3264 __i %= static_cast<int>(__n);
3265 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3266 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3267 ::new ((void*)__r.__end_) value_type(*__s);
3268 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3269 ::new ((void*)__r.__end_) value_type(*__s);
3274 template <class _Tp>
3276 valarray<_Tp>::apply(value_type __f(value_type)) const
3278 valarray<value_type> __r;
3279 size_t __n = size();
3282 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3283 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3284 ::new ((void*)__r.__end_) value_type(__f(*__p));
3289 template <class _Tp>
3291 valarray<_Tp>::apply(value_type __f(const value_type&)) const
3293 valarray<value_type> __r;
3294 size_t __n = size();
3297 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3298 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3299 ::new ((void*)__r.__end_) value_type(__f(*__p));
3304 template <class _Tp>
3306 void valarray<_Tp>::__clear(size_t __capacity)
3308 if (__begin_ != nullptr)
3310 while (__end_ != __begin_)
3311 (--__end_)->~value_type();
3312 allocator<value_type>().deallocate(__begin_, __capacity);
3313 __begin_ = __end_ = nullptr;
3317 template <class _Tp>
3319 valarray<_Tp>::resize(size_t __n, value_type __x)
3324 __begin_ = __end_ = allocator<value_type>().allocate(__n);
3325 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
3328 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
3329 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
3330 ::new ((void*)__end_) value_type(__x);
3331 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
3338 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
3343 inline _LIBCPP_INLINE_VISIBILITY
3345 swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
3350 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3351 inline _LIBCPP_INLINE_VISIBILITY
3352 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3353 operator*(const _Expr1& __x, const _Expr2& __y)
3355 typedef typename _Expr1::value_type value_type;
3356 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3357 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3360 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3361 inline _LIBCPP_INLINE_VISIBILITY
3362 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3363 _Expr, __scalar_expr<typename _Expr::value_type> > >
3364 operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3366 typedef typename _Expr::value_type value_type;
3367 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3368 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3369 __x, __scalar_expr<value_type>(__y, __x.size())));
3372 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3373 inline _LIBCPP_INLINE_VISIBILITY
3374 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3375 __scalar_expr<typename _Expr::value_type>, _Expr> >
3376 operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3378 typedef typename _Expr::value_type value_type;
3379 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3380 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3381 __scalar_expr<value_type>(__x, __y.size()), __y));
3384 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3385 inline _LIBCPP_INLINE_VISIBILITY
3386 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3387 operator/(const _Expr1& __x, const _Expr2& __y)
3389 typedef typename _Expr1::value_type value_type;
3390 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3391 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3394 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3395 inline _LIBCPP_INLINE_VISIBILITY
3396 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3397 _Expr, __scalar_expr<typename _Expr::value_type> > >
3398 operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3400 typedef typename _Expr::value_type value_type;
3401 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3402 return __val_expr<_Op>(_Op(divides<value_type>(),
3403 __x, __scalar_expr<value_type>(__y, __x.size())));
3406 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3407 inline _LIBCPP_INLINE_VISIBILITY
3408 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3409 __scalar_expr<typename _Expr::value_type>, _Expr> >
3410 operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3412 typedef typename _Expr::value_type value_type;
3413 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3414 return __val_expr<_Op>(_Op(divides<value_type>(),
3415 __scalar_expr<value_type>(__x, __y.size()), __y));
3418 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3419 inline _LIBCPP_INLINE_VISIBILITY
3420 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3421 operator%(const _Expr1& __x, const _Expr2& __y)
3423 typedef typename _Expr1::value_type value_type;
3424 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3425 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3428 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3429 inline _LIBCPP_INLINE_VISIBILITY
3430 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3431 _Expr, __scalar_expr<typename _Expr::value_type> > >
3432 operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3434 typedef typename _Expr::value_type value_type;
3435 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3436 return __val_expr<_Op>(_Op(modulus<value_type>(),
3437 __x, __scalar_expr<value_type>(__y, __x.size())));
3440 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3441 inline _LIBCPP_INLINE_VISIBILITY
3442 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3443 __scalar_expr<typename _Expr::value_type>, _Expr> >
3444 operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3446 typedef typename _Expr::value_type value_type;
3447 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3448 return __val_expr<_Op>(_Op(modulus<value_type>(),
3449 __scalar_expr<value_type>(__x, __y.size()), __y));
3452 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3453 inline _LIBCPP_INLINE_VISIBILITY
3454 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3455 operator+(const _Expr1& __x, const _Expr2& __y)
3457 typedef typename _Expr1::value_type value_type;
3458 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3459 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3462 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3463 inline _LIBCPP_INLINE_VISIBILITY
3464 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3465 _Expr, __scalar_expr<typename _Expr::value_type> > >
3466 operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3468 typedef typename _Expr::value_type value_type;
3469 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3470 return __val_expr<_Op>(_Op(plus<value_type>(),
3471 __x, __scalar_expr<value_type>(__y, __x.size())));
3474 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3475 inline _LIBCPP_INLINE_VISIBILITY
3476 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3477 __scalar_expr<typename _Expr::value_type>, _Expr> >
3478 operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3480 typedef typename _Expr::value_type value_type;
3481 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3482 return __val_expr<_Op>(_Op(plus<value_type>(),
3483 __scalar_expr<value_type>(__x, __y.size()), __y));
3486 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3487 inline _LIBCPP_INLINE_VISIBILITY
3488 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3489 operator-(const _Expr1& __x, const _Expr2& __y)
3491 typedef typename _Expr1::value_type value_type;
3492 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3493 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3496 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3497 inline _LIBCPP_INLINE_VISIBILITY
3498 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3499 _Expr, __scalar_expr<typename _Expr::value_type> > >
3500 operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3502 typedef typename _Expr::value_type value_type;
3503 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3504 return __val_expr<_Op>(_Op(minus<value_type>(),
3505 __x, __scalar_expr<value_type>(__y, __x.size())));
3508 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3509 inline _LIBCPP_INLINE_VISIBILITY
3510 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3511 __scalar_expr<typename _Expr::value_type>, _Expr> >
3512 operator-(const typename _Expr::value_type& __x, const _Expr& __y)
3514 typedef typename _Expr::value_type value_type;
3515 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3516 return __val_expr<_Op>(_Op(minus<value_type>(),
3517 __scalar_expr<value_type>(__x, __y.size()), __y));
3520 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3521 inline _LIBCPP_INLINE_VISIBILITY
3522 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
3523 operator^(const _Expr1& __x, const _Expr2& __y)
3525 typedef typename _Expr1::value_type value_type;
3526 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
3527 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
3530 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3531 inline _LIBCPP_INLINE_VISIBILITY
3532 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3533 _Expr, __scalar_expr<typename _Expr::value_type> > >
3534 operator^(const _Expr& __x, const typename _Expr::value_type& __y)
3536 typedef typename _Expr::value_type value_type;
3537 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3538 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3539 __x, __scalar_expr<value_type>(__y, __x.size())));
3542 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3543 inline _LIBCPP_INLINE_VISIBILITY
3544 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3545 __scalar_expr<typename _Expr::value_type>, _Expr> >
3546 operator^(const typename _Expr::value_type& __x, const _Expr& __y)
3548 typedef typename _Expr::value_type value_type;
3549 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3550 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3551 __scalar_expr<value_type>(__x, __y.size()), __y));
3554 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3555 inline _LIBCPP_INLINE_VISIBILITY
3556 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
3557 operator&(const _Expr1& __x, const _Expr2& __y)
3559 typedef typename _Expr1::value_type value_type;
3560 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
3561 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
3564 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3565 inline _LIBCPP_INLINE_VISIBILITY
3566 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
3567 _Expr, __scalar_expr<typename _Expr::value_type> > >
3568 operator&(const _Expr& __x, const typename _Expr::value_type& __y)
3570 typedef typename _Expr::value_type value_type;
3571 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3572 return __val_expr<_Op>(_Op(bit_and<value_type>(),
3573 __x, __scalar_expr<value_type>(__y, __x.size())));
3576 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3577 inline _LIBCPP_INLINE_VISIBILITY
3578 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
3579 __scalar_expr<typename _Expr::value_type>, _Expr> >
3580 operator&(const typename _Expr::value_type& __x, const _Expr& __y)
3582 typedef typename _Expr::value_type value_type;
3583 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3584 return __val_expr<_Op>(_Op(bit_and<value_type>(),
3585 __scalar_expr<value_type>(__x, __y.size()), __y));
3588 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3589 inline _LIBCPP_INLINE_VISIBILITY
3590 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
3591 operator|(const _Expr1& __x, const _Expr2& __y)
3593 typedef typename _Expr1::value_type value_type;
3594 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
3595 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
3598 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3599 inline _LIBCPP_INLINE_VISIBILITY
3600 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
3601 _Expr, __scalar_expr<typename _Expr::value_type> > >
3602 operator|(const _Expr& __x, const typename _Expr::value_type& __y)
3604 typedef typename _Expr::value_type value_type;
3605 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3606 return __val_expr<_Op>(_Op(bit_or<value_type>(),
3607 __x, __scalar_expr<value_type>(__y, __x.size())));
3610 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3611 inline _LIBCPP_INLINE_VISIBILITY
3612 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
3613 __scalar_expr<typename _Expr::value_type>, _Expr> >
3614 operator|(const typename _Expr::value_type& __x, const _Expr& __y)
3616 typedef typename _Expr::value_type value_type;
3617 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3618 return __val_expr<_Op>(_Op(bit_or<value_type>(),
3619 __scalar_expr<value_type>(__x, __y.size()), __y));
3622 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3623 inline _LIBCPP_INLINE_VISIBILITY
3624 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
3625 operator<<(const _Expr1& __x, const _Expr2& __y)
3627 typedef typename _Expr1::value_type value_type;
3628 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
3629 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
3632 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3633 inline _LIBCPP_INLINE_VISIBILITY
3634 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
3635 _Expr, __scalar_expr<typename _Expr::value_type> > >
3636 operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
3638 typedef typename _Expr::value_type value_type;
3639 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3640 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
3641 __x, __scalar_expr<value_type>(__y, __x.size())));
3644 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3645 inline _LIBCPP_INLINE_VISIBILITY
3646 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
3647 __scalar_expr<typename _Expr::value_type>, _Expr> >
3648 operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
3650 typedef typename _Expr::value_type value_type;
3651 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3652 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
3653 __scalar_expr<value_type>(__x, __y.size()), __y));
3656 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3657 inline _LIBCPP_INLINE_VISIBILITY
3658 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
3659 operator>>(const _Expr1& __x, const _Expr2& __y)
3661 typedef typename _Expr1::value_type value_type;
3662 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
3663 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
3666 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3667 inline _LIBCPP_INLINE_VISIBILITY
3668 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
3669 _Expr, __scalar_expr<typename _Expr::value_type> > >
3670 operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
3672 typedef typename _Expr::value_type value_type;
3673 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3674 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
3675 __x, __scalar_expr<value_type>(__y, __x.size())));
3678 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3679 inline _LIBCPP_INLINE_VISIBILITY
3680 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
3681 __scalar_expr<typename _Expr::value_type>, _Expr> >
3682 operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
3684 typedef typename _Expr::value_type value_type;
3685 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3686 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
3687 __scalar_expr<value_type>(__x, __y.size()), __y));
3690 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3691 inline _LIBCPP_INLINE_VISIBILITY
3692 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
3693 operator&&(const _Expr1& __x, const _Expr2& __y)
3695 typedef typename _Expr1::value_type value_type;
3696 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
3697 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
3700 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3701 inline _LIBCPP_INLINE_VISIBILITY
3702 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
3703 _Expr, __scalar_expr<typename _Expr::value_type> > >
3704 operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
3706 typedef typename _Expr::value_type value_type;
3707 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3708 return __val_expr<_Op>(_Op(logical_and<value_type>(),
3709 __x, __scalar_expr<value_type>(__y, __x.size())));
3712 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3713 inline _LIBCPP_INLINE_VISIBILITY
3714 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
3715 __scalar_expr<typename _Expr::value_type>, _Expr> >
3716 operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
3718 typedef typename _Expr::value_type value_type;
3719 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3720 return __val_expr<_Op>(_Op(logical_and<value_type>(),
3721 __scalar_expr<value_type>(__x, __y.size()), __y));
3724 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3725 inline _LIBCPP_INLINE_VISIBILITY
3726 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
3727 operator||(const _Expr1& __x, const _Expr2& __y)
3729 typedef typename _Expr1::value_type value_type;
3730 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
3731 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
3734 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3735 inline _LIBCPP_INLINE_VISIBILITY
3736 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
3737 _Expr, __scalar_expr<typename _Expr::value_type> > >
3738 operator||(const _Expr& __x, const typename _Expr::value_type& __y)
3740 typedef typename _Expr::value_type value_type;
3741 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3742 return __val_expr<_Op>(_Op(logical_or<value_type>(),
3743 __x, __scalar_expr<value_type>(__y, __x.size())));
3746 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3747 inline _LIBCPP_INLINE_VISIBILITY
3748 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
3749 __scalar_expr<typename _Expr::value_type>, _Expr> >
3750 operator||(const typename _Expr::value_type& __x, const _Expr& __y)
3752 typedef typename _Expr::value_type value_type;
3753 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3754 return __val_expr<_Op>(_Op(logical_or<value_type>(),
3755 __scalar_expr<value_type>(__x, __y.size()), __y));
3758 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3759 inline _LIBCPP_INLINE_VISIBILITY
3760 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
3761 operator==(const _Expr1& __x, const _Expr2& __y)
3763 typedef typename _Expr1::value_type value_type;
3764 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
3765 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
3768 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3769 inline _LIBCPP_INLINE_VISIBILITY
3770 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
3771 _Expr, __scalar_expr<typename _Expr::value_type> > >
3772 operator==(const _Expr& __x, const typename _Expr::value_type& __y)
3774 typedef typename _Expr::value_type value_type;
3775 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3776 return __val_expr<_Op>(_Op(equal_to<value_type>(),
3777 __x, __scalar_expr<value_type>(__y, __x.size())));
3780 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3781 inline _LIBCPP_INLINE_VISIBILITY
3782 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
3783 __scalar_expr<typename _Expr::value_type>, _Expr> >
3784 operator==(const typename _Expr::value_type& __x, const _Expr& __y)
3786 typedef typename _Expr::value_type value_type;
3787 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3788 return __val_expr<_Op>(_Op(equal_to<value_type>(),
3789 __scalar_expr<value_type>(__x, __y.size()), __y));
3792 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3793 inline _LIBCPP_INLINE_VISIBILITY
3794 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
3795 operator!=(const _Expr1& __x, const _Expr2& __y)
3797 typedef typename _Expr1::value_type value_type;
3798 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
3799 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
3802 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3803 inline _LIBCPP_INLINE_VISIBILITY
3804 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
3805 _Expr, __scalar_expr<typename _Expr::value_type> > >
3806 operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
3808 typedef typename _Expr::value_type value_type;
3809 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3810 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
3811 __x, __scalar_expr<value_type>(__y, __x.size())));
3814 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3815 inline _LIBCPP_INLINE_VISIBILITY
3816 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
3817 __scalar_expr<typename _Expr::value_type>, _Expr> >
3818 operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
3820 typedef typename _Expr::value_type value_type;
3821 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3822 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
3823 __scalar_expr<value_type>(__x, __y.size()), __y));
3826 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3827 inline _LIBCPP_INLINE_VISIBILITY
3828 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
3829 operator<(const _Expr1& __x, const _Expr2& __y)
3831 typedef typename _Expr1::value_type value_type;
3832 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
3833 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
3836 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3837 inline _LIBCPP_INLINE_VISIBILITY
3838 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
3839 _Expr, __scalar_expr<typename _Expr::value_type> > >
3840 operator<(const _Expr& __x, const typename _Expr::value_type& __y)
3842 typedef typename _Expr::value_type value_type;
3843 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3844 return __val_expr<_Op>(_Op(less<value_type>(),
3845 __x, __scalar_expr<value_type>(__y, __x.size())));
3848 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3849 inline _LIBCPP_INLINE_VISIBILITY
3850 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
3851 __scalar_expr<typename _Expr::value_type>, _Expr> >
3852 operator<(const typename _Expr::value_type& __x, const _Expr& __y)
3854 typedef typename _Expr::value_type value_type;
3855 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3856 return __val_expr<_Op>(_Op(less<value_type>(),
3857 __scalar_expr<value_type>(__x, __y.size()), __y));
3860 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3861 inline _LIBCPP_INLINE_VISIBILITY
3862 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
3863 operator>(const _Expr1& __x, const _Expr2& __y)
3865 typedef typename _Expr1::value_type value_type;
3866 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
3867 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
3870 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3871 inline _LIBCPP_INLINE_VISIBILITY
3872 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
3873 _Expr, __scalar_expr<typename _Expr::value_type> > >
3874 operator>(const _Expr& __x, const typename _Expr::value_type& __y)
3876 typedef typename _Expr::value_type value_type;
3877 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3878 return __val_expr<_Op>(_Op(greater<value_type>(),
3879 __x, __scalar_expr<value_type>(__y, __x.size())));
3882 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3883 inline _LIBCPP_INLINE_VISIBILITY
3884 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
3885 __scalar_expr<typename _Expr::value_type>, _Expr> >
3886 operator>(const typename _Expr::value_type& __x, const _Expr& __y)
3888 typedef typename _Expr::value_type value_type;
3889 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3890 return __val_expr<_Op>(_Op(greater<value_type>(),
3891 __scalar_expr<value_type>(__x, __y.size()), __y));
3894 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3895 inline _LIBCPP_INLINE_VISIBILITY
3896 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
3897 operator<=(const _Expr1& __x, const _Expr2& __y)
3899 typedef typename _Expr1::value_type value_type;
3900 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
3901 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
3904 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3905 inline _LIBCPP_INLINE_VISIBILITY
3906 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
3907 _Expr, __scalar_expr<typename _Expr::value_type> > >
3908 operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
3910 typedef typename _Expr::value_type value_type;
3911 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3912 return __val_expr<_Op>(_Op(less_equal<value_type>(),
3913 __x, __scalar_expr<value_type>(__y, __x.size())));
3916 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3917 inline _LIBCPP_INLINE_VISIBILITY
3918 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
3919 __scalar_expr<typename _Expr::value_type>, _Expr> >
3920 operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
3922 typedef typename _Expr::value_type value_type;
3923 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3924 return __val_expr<_Op>(_Op(less_equal<value_type>(),
3925 __scalar_expr<value_type>(__x, __y.size()), __y));
3928 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3929 inline _LIBCPP_INLINE_VISIBILITY
3930 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
3931 operator>=(const _Expr1& __x, const _Expr2& __y)
3933 typedef typename _Expr1::value_type value_type;
3934 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
3935 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
3938 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3939 inline _LIBCPP_INLINE_VISIBILITY
3940 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
3941 _Expr, __scalar_expr<typename _Expr::value_type> > >
3942 operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
3944 typedef typename _Expr::value_type value_type;
3945 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3946 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
3947 __x, __scalar_expr<value_type>(__y, __x.size())));
3950 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3951 inline _LIBCPP_INLINE_VISIBILITY
3952 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
3953 __scalar_expr<typename _Expr::value_type>, _Expr> >
3954 operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
3956 typedef typename _Expr::value_type value_type;
3957 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3958 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
3959 __scalar_expr<value_type>(__x, __y.size()), __y));
3962 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3963 inline _LIBCPP_INLINE_VISIBILITY
3964 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
3965 abs(const _Expr& __x)
3967 typedef typename _Expr::value_type value_type;
3968 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
3969 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
3972 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3973 inline _LIBCPP_INLINE_VISIBILITY
3974 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
3975 acos(const _Expr& __x)
3977 typedef typename _Expr::value_type value_type;
3978 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
3979 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
3982 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3983 inline _LIBCPP_INLINE_VISIBILITY
3984 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
3985 asin(const _Expr& __x)
3987 typedef typename _Expr::value_type value_type;
3988 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
3989 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
3992 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3993 inline _LIBCPP_INLINE_VISIBILITY
3994 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
3995 atan(const _Expr& __x)
3997 typedef typename _Expr::value_type value_type;
3998 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
3999 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4002 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
4003 inline _LIBCPP_INLINE_VISIBILITY
4004 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4005 atan2(const _Expr1& __x, const _Expr2& __y)
4007 typedef typename _Expr1::value_type value_type;
4008 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4009 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4012 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4013 inline _LIBCPP_INLINE_VISIBILITY
4014 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4015 _Expr, __scalar_expr<typename _Expr::value_type> > >
4016 atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4018 typedef typename _Expr::value_type value_type;
4019 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4020 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4021 __x, __scalar_expr<value_type>(__y, __x.size())));
4024 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4025 inline _LIBCPP_INLINE_VISIBILITY
4026 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4027 __scalar_expr<typename _Expr::value_type>, _Expr> >
4028 atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4030 typedef typename _Expr::value_type value_type;
4031 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4032 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4033 __scalar_expr<value_type>(__x, __y.size()), __y));
4036 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4037 inline _LIBCPP_INLINE_VISIBILITY
4038 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4039 cos(const _Expr& __x)
4041 typedef typename _Expr::value_type value_type;
4042 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4043 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4046 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4047 inline _LIBCPP_INLINE_VISIBILITY
4048 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4049 cosh(const _Expr& __x)
4051 typedef typename _Expr::value_type value_type;
4052 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4053 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4056 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4057 inline _LIBCPP_INLINE_VISIBILITY
4058 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4059 exp(const _Expr& __x)
4061 typedef typename _Expr::value_type value_type;
4062 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4063 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4066 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4067 inline _LIBCPP_INLINE_VISIBILITY
4068 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4069 log(const _Expr& __x)
4071 typedef typename _Expr::value_type value_type;
4072 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4073 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4076 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4077 inline _LIBCPP_INLINE_VISIBILITY
4078 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4079 log10(const _Expr& __x)
4081 typedef typename _Expr::value_type value_type;
4082 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4083 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4086 template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
4087 inline _LIBCPP_INLINE_VISIBILITY
4088 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4089 pow(const _Expr1& __x, const _Expr2& __y)
4091 typedef typename _Expr1::value_type value_type;
4092 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4093 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4096 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4097 inline _LIBCPP_INLINE_VISIBILITY
4098 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4099 _Expr, __scalar_expr<typename _Expr::value_type> > >
4100 pow(const _Expr& __x, const typename _Expr::value_type& __y)
4102 typedef typename _Expr::value_type value_type;
4103 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4104 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4105 __x, __scalar_expr<value_type>(__y, __x.size())));
4108 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4109 inline _LIBCPP_INLINE_VISIBILITY
4110 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4111 __scalar_expr<typename _Expr::value_type>, _Expr> >
4112 pow(const typename _Expr::value_type& __x, const _Expr& __y)
4114 typedef typename _Expr::value_type value_type;
4115 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4116 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4117 __scalar_expr<value_type>(__x, __y.size()), __y));
4120 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4121 inline _LIBCPP_INLINE_VISIBILITY
4122 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4123 sin(const _Expr& __x)
4125 typedef typename _Expr::value_type value_type;
4126 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4127 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4130 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4131 inline _LIBCPP_INLINE_VISIBILITY
4132 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4133 sinh(const _Expr& __x)
4135 typedef typename _Expr::value_type value_type;
4136 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4137 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4140 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4141 inline _LIBCPP_INLINE_VISIBILITY
4142 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4143 sqrt(const _Expr& __x)
4145 typedef typename _Expr::value_type value_type;
4146 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4147 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4150 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4151 inline _LIBCPP_INLINE_VISIBILITY
4152 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4153 tan(const _Expr& __x)
4155 typedef typename _Expr::value_type value_type;
4156 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4157 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4160 template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
4161 inline _LIBCPP_INLINE_VISIBILITY
4162 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4163 tanh(const _Expr& __x)
4165 typedef typename _Expr::value_type value_type;
4166 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4167 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4170 template <class _Tp>
4171 inline _LIBCPP_INLINE_VISIBILITY
4173 begin(valarray<_Tp>& __v)
4175 return __v.__begin_;
4178 template <class _Tp>
4179 inline _LIBCPP_INLINE_VISIBILITY
4181 begin(const valarray<_Tp>& __v)
4183 return __v.__begin_;
4186 template <class _Tp>
4187 inline _LIBCPP_INLINE_VISIBILITY
4189 end(valarray<_Tp>& __v)
4194 template <class _Tp>
4195 inline _LIBCPP_INLINE_VISIBILITY
4197 end(const valarray<_Tp>& __v)
4202 _LIBCPP_END_NAMESPACE_STD
4206 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
4207 # include <algorithm>
4208 # include <concepts>
4211 # include <functional>
4212 # include <stdexcept>
4213 # include <type_traits>
4216 #endif // _LIBCPP_VALARRAY