Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/c++/v1/__cxx03/valarray is written in an unsupported language. File is not indexed.

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03_VALARRAY
0011 #define _LIBCPP___CXX03_VALARRAY
0012 
0013 /*
0014     valarray synopsis
0015 
0016 namespace std
0017 {
0018 
0019 template<class T>
0020 class valarray
0021 {
0022 public:
0023     typedef T value_type;
0024 
0025     // construct/destroy:
0026     valarray();
0027     explicit valarray(size_t n);
0028     valarray(const value_type& x, size_t n);
0029     valarray(const value_type* px, size_t n);
0030     valarray(const valarray& v);
0031     valarray(valarray&& v) noexcept;
0032     valarray(const slice_array<value_type>& sa);
0033     valarray(const gslice_array<value_type>& ga);
0034     valarray(const mask_array<value_type>& ma);
0035     valarray(const indirect_array<value_type>& ia);
0036     valarray(initializer_list<value_type> il);
0037     ~valarray();
0038 
0039     // assignment:
0040     valarray& operator=(const valarray& v);
0041     valarray& operator=(valarray&& v) noexcept;
0042     valarray& operator=(initializer_list<value_type> il);
0043     valarray& operator=(const value_type& x);
0044     valarray& operator=(const slice_array<value_type>& sa);
0045     valarray& operator=(const gslice_array<value_type>& ga);
0046     valarray& operator=(const mask_array<value_type>& ma);
0047     valarray& operator=(const indirect_array<value_type>& ia);
0048 
0049     // element access:
0050     const value_type& operator[](size_t i) const;
0051     value_type&       operator[](size_t i);
0052 
0053     // subset operations:
0054     valarray                   operator[](slice s) const;
0055     slice_array<value_type>    operator[](slice s);
0056     valarray                   operator[](const gslice& gs) const;
0057     gslice_array<value_type>   operator[](const gslice& gs);
0058     valarray                   operator[](const valarray<bool>& vb) const;
0059     mask_array<value_type>     operator[](const valarray<bool>& vb);
0060     valarray                   operator[](const valarray<size_t>& vs) const;
0061     indirect_array<value_type> operator[](const valarray<size_t>& vs);
0062 
0063     // unary operators:
0064     valarray       operator+() const;
0065     valarray       operator-() const;
0066     valarray       operator~() const;
0067     valarray<bool> operator!() const;
0068 
0069     // computed assignment:
0070     valarray& operator*= (const value_type& x);
0071     valarray& operator/= (const value_type& x);
0072     valarray& operator%= (const value_type& x);
0073     valarray& operator+= (const value_type& x);
0074     valarray& operator-= (const value_type& x);
0075     valarray& operator^= (const value_type& x);
0076     valarray& operator&= (const value_type& x);
0077     valarray& operator|= (const value_type& x);
0078     valarray& operator<<=(const value_type& x);
0079     valarray& operator>>=(const value_type& x);
0080 
0081     valarray& operator*= (const valarray& v);
0082     valarray& operator/= (const valarray& v);
0083     valarray& operator%= (const valarray& v);
0084     valarray& operator+= (const valarray& v);
0085     valarray& operator-= (const valarray& v);
0086     valarray& operator^= (const valarray& v);
0087     valarray& operator|= (const valarray& v);
0088     valarray& operator&= (const valarray& v);
0089     valarray& operator<<=(const valarray& v);
0090     valarray& operator>>=(const valarray& v);
0091 
0092     // member functions:
0093     void swap(valarray& v) noexcept;
0094 
0095     size_t size() const;
0096 
0097     value_type sum() const;
0098     value_type min() const;
0099     value_type max() const;
0100 
0101     valarray shift (int i) const;
0102     valarray cshift(int i) const;
0103     valarray apply(value_type f(value_type)) const;
0104     valarray apply(value_type f(const value_type&)) const;
0105     void resize(size_t n, value_type x = value_type());
0106 };
0107 
0108 template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>;
0109 
0110 class slice
0111 {
0112 public:
0113     slice();
0114     slice(size_t start, size_t size, size_t stride);
0115 
0116     size_t start()  const;
0117     size_t size()   const;
0118     size_t stride() const;
0119 
0120     friend bool operator==(const slice& x, const slice& y); // since C++20
0121 };
0122 
0123 template <class T>
0124 class slice_array
0125 {
0126 public:
0127     typedef T value_type;
0128 
0129     const slice_array& operator=(const slice_array& sa) const;
0130     void operator=  (const valarray<value_type>& v) const;
0131     void operator*= (const valarray<value_type>& v) const;
0132     void operator/= (const valarray<value_type>& v) const;
0133     void operator%= (const valarray<value_type>& v) const;
0134     void operator+= (const valarray<value_type>& v) const;
0135     void operator-= (const valarray<value_type>& v) const;
0136     void operator^= (const valarray<value_type>& v) const;
0137     void operator&= (const valarray<value_type>& v) const;
0138     void operator|= (const valarray<value_type>& v) const;
0139     void operator<<=(const valarray<value_type>& v) const;
0140     void operator>>=(const valarray<value_type>& v) const;
0141 
0142     void operator=(const value_type& x) const;
0143     void operator=(const valarray<T>& val_arr) const;
0144 
0145     slice_array() = delete;
0146 };
0147 
0148 class gslice
0149 {
0150 public:
0151     gslice();
0152     gslice(size_t start, const valarray<size_t>& size,
0153                          const valarray<size_t>& stride);
0154 
0155     size_t           start()  const;
0156     valarray<size_t> size()   const;
0157     valarray<size_t> stride() const;
0158 };
0159 
0160 template <class T>
0161 class gslice_array
0162 {
0163 public:
0164     typedef T value_type;
0165 
0166     void operator=  (const valarray<value_type>& v) const;
0167     void operator*= (const valarray<value_type>& v) const;
0168     void operator/= (const valarray<value_type>& v) const;
0169     void operator%= (const valarray<value_type>& v) const;
0170     void operator+= (const valarray<value_type>& v) const;
0171     void operator-= (const valarray<value_type>& v) const;
0172     void operator^= (const valarray<value_type>& v) const;
0173     void operator&= (const valarray<value_type>& v) const;
0174     void operator|= (const valarray<value_type>& v) const;
0175     void operator<<=(const valarray<value_type>& v) const;
0176     void operator>>=(const valarray<value_type>& v) const;
0177 
0178     gslice_array(const gslice_array& ga);
0179     ~gslice_array();
0180     const gslice_array& operator=(const gslice_array& ga) const;
0181     void operator=(const value_type& x) const;
0182 
0183     gslice_array() = delete;
0184 };
0185 
0186 template <class T>
0187 class mask_array
0188 {
0189 public:
0190     typedef T value_type;
0191 
0192     void operator=  (const valarray<value_type>& v) const;
0193     void operator*= (const valarray<value_type>& v) const;
0194     void operator/= (const valarray<value_type>& v) const;
0195     void operator%= (const valarray<value_type>& v) const;
0196     void operator+= (const valarray<value_type>& v) const;
0197     void operator-= (const valarray<value_type>& v) const;
0198     void operator^= (const valarray<value_type>& v) const;
0199     void operator&= (const valarray<value_type>& v) const;
0200     void operator|= (const valarray<value_type>& v) const;
0201     void operator<<=(const valarray<value_type>& v) const;
0202     void operator>>=(const valarray<value_type>& v) const;
0203 
0204     mask_array(const mask_array& ma);
0205     ~mask_array();
0206     const mask_array& operator=(const mask_array& ma) const;
0207     void operator=(const value_type& x) const;
0208 
0209     mask_array() = delete;
0210 };
0211 
0212 template <class T>
0213 class indirect_array
0214 {
0215 public:
0216     typedef T value_type;
0217 
0218     void operator=  (const valarray<value_type>& v) const;
0219     void operator*= (const valarray<value_type>& v) const;
0220     void operator/= (const valarray<value_type>& v) const;
0221     void operator%= (const valarray<value_type>& v) const;
0222     void operator+= (const valarray<value_type>& v) const;
0223     void operator-= (const valarray<value_type>& v) const;
0224     void operator^= (const valarray<value_type>& v) const;
0225     void operator&= (const valarray<value_type>& v) const;
0226     void operator|= (const valarray<value_type>& v) const;
0227     void operator<<=(const valarray<value_type>& v) const;
0228     void operator>>=(const valarray<value_type>& v) const;
0229 
0230     indirect_array(const indirect_array& ia);
0231     ~indirect_array();
0232     const indirect_array& operator=(const indirect_array& ia) const;
0233     void operator=(const value_type& x) const;
0234 
0235     indirect_array() = delete;
0236 };
0237 
0238 template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
0239 
0240 template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
0241 template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
0242 template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
0243 
0244 template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
0245 template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
0246 template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
0247 
0248 template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
0249 template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
0250 template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
0251 
0252 template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
0253 template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
0254 template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
0255 
0256 template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
0257 template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
0258 template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
0259 
0260 template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
0261 template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
0262 template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
0263 
0264 template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
0265 template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
0266 template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
0267 
0268 template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
0269 template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
0270 template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
0271 
0272 template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
0273 template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
0274 template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
0275 
0276 template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
0277 template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
0278 template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
0279 
0280 template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
0281 template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
0282 template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
0283 
0284 template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
0285 template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
0286 template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
0287 
0288 template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
0289 template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
0290 template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
0291 
0292 template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
0293 template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
0294 template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
0295 
0296 template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
0297 template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
0298 template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
0299 
0300 template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
0301 template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
0302 template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
0303 
0304 template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
0305 template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
0306 template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
0307 
0308 template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
0309 template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
0310 template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
0311 
0312 template<class T> valarray<T> abs (const valarray<T>& x);
0313 template<class T> valarray<T> acos (const valarray<T>& x);
0314 template<class T> valarray<T> asin (const valarray<T>& x);
0315 template<class T> valarray<T> atan (const valarray<T>& x);
0316 
0317 template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
0318 template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
0319 template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
0320 
0321 template<class T> valarray<T> cos (const valarray<T>& x);
0322 template<class T> valarray<T> cosh (const valarray<T>& x);
0323 template<class T> valarray<T> exp (const valarray<T>& x);
0324 template<class T> valarray<T> log (const valarray<T>& x);
0325 template<class T> valarray<T> log10(const valarray<T>& x);
0326 
0327 template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
0328 template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
0329 template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
0330 
0331 template<class T> valarray<T> sin (const valarray<T>& x);
0332 template<class T> valarray<T> sinh (const valarray<T>& x);
0333 template<class T> valarray<T> sqrt (const valarray<T>& x);
0334 template<class T> valarray<T> tan (const valarray<T>& x);
0335 template<class T> valarray<T> tanh (const valarray<T>& x);
0336 
0337 template <class T> unspecified1 begin(valarray<T>& v);
0338 template <class T> unspecified2 begin(const valarray<T>& v);
0339 template <class T> unspecified1 end(valarray<T>& v);
0340 template <class T> unspecified2 end(const valarray<T>& v);
0341 
0342 }  // std
0343 
0344 */
0345 
0346 #include <__cxx03/__algorithm/copy.h>
0347 #include <__cxx03/__algorithm/count.h>
0348 #include <__cxx03/__algorithm/fill.h>
0349 #include <__cxx03/__algorithm/max_element.h>
0350 #include <__cxx03/__algorithm/min.h>
0351 #include <__cxx03/__algorithm/min_element.h>
0352 #include <__cxx03/__algorithm/unwrap_iter.h>
0353 #include <__cxx03/__assert>
0354 #include <__cxx03/__config>
0355 #include <__cxx03/__functional/operations.h>
0356 #include <__cxx03/__memory/addressof.h>
0357 #include <__cxx03/__memory/allocator.h>
0358 #include <__cxx03/__memory/uninitialized_algorithms.h>
0359 #include <__cxx03/__type_traits/decay.h>
0360 #include <__cxx03/__type_traits/remove_reference.h>
0361 #include <__cxx03/__utility/move.h>
0362 #include <__cxx03/__utility/swap.h>
0363 #include <__cxx03/cmath>
0364 #include <__cxx03/cstddef>
0365 #include <__cxx03/new>
0366 #include <__cxx03/version>
0367 
0368 // standard-mandated includes
0369 
0370 // [valarray.syn]
0371 #include <__cxx03/initializer_list>
0372 
0373 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0374 #  pragma GCC system_header
0375 #endif
0376 
0377 _LIBCPP_PUSH_MACROS
0378 #include <__cxx03/__undef_macros>
0379 
0380 _LIBCPP_BEGIN_NAMESPACE_STD
0381 
0382 template <class _Tp>
0383 class _LIBCPP_TEMPLATE_VIS valarray;
0384 
0385 class _LIBCPP_TEMPLATE_VIS slice {
0386   size_t __start_;
0387   size_t __size_;
0388   size_t __stride_;
0389 
0390 public:
0391   _LIBCPP_HIDE_FROM_ABI slice() : __start_(0), __size_(0), __stride_(0) {}
0392 
0393   _LIBCPP_HIDE_FROM_ABI slice(size_t __start, size_t __size, size_t __stride)
0394       : __start_(__start), __size_(__size), __stride_(__stride) {}
0395 
0396   _LIBCPP_HIDE_FROM_ABI size_t start() const { return __start_; }
0397   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
0398   _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; }
0399 
0400 #if _LIBCPP_STD_VER >= 20
0401 
0402   _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) {
0403     return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride();
0404   }
0405 
0406 #endif
0407 };
0408 
0409 template <class _Tp>
0410 class _LIBCPP_TEMPLATE_VIS slice_array;
0411 class _LIBCPP_EXPORTED_FROM_ABI gslice;
0412 template <class _Tp>
0413 class _LIBCPP_TEMPLATE_VIS gslice_array;
0414 template <class _Tp>
0415 class _LIBCPP_TEMPLATE_VIS mask_array;
0416 template <class _Tp>
0417 class _LIBCPP_TEMPLATE_VIS indirect_array;
0418 
0419 template <class _Tp>
0420 _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v);
0421 
0422 template <class _Tp>
0423 _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v);
0424 
0425 template <class _Tp>
0426 _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v);
0427 
0428 template <class _Tp>
0429 _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v);
0430 
0431 template <class _Op, class _A0>
0432 struct _UnaryOp {
0433   typedef typename _Op::__result_type __result_type;
0434   using value_type = __decay_t<__result_type>;
0435 
0436   _Op __op_;
0437   _A0 __a0_;
0438 
0439   _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
0440 
0441   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); }
0442 
0443   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
0444 };
0445 
0446 template <class _Op, class _A0, class _A1>
0447 struct _BinaryOp {
0448   typedef typename _Op::__result_type __result_type;
0449   using value_type = __decay_t<__result_type>;
0450 
0451   _Op __op_;
0452   _A0 __a0_;
0453   _A1 __a1_;
0454 
0455   _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
0456       : __op_(__op), __a0_(__a0), __a1_(__a1) {}
0457 
0458   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }
0459 
0460   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
0461 };
0462 
0463 template <class _Tp>
0464 class __scalar_expr {
0465 public:
0466   typedef _Tp value_type;
0467   typedef const _Tp& __result_type;
0468 
0469 private:
0470   const value_type& __t_;
0471   size_t __s_;
0472 
0473 public:
0474   _LIBCPP_HIDE_FROM_ABI explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
0475 
0476   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t) const { return __t_; }
0477 
0478   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __s_; }
0479 };
0480 
0481 template <class _Tp>
0482 struct __unary_plus {
0483   typedef _Tp __result_type;
0484   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return +__x; }
0485 };
0486 
0487 template <class _Tp>
0488 struct __bit_not {
0489   typedef _Tp __result_type;
0490   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }
0491 };
0492 
0493 template <class _Tp>
0494 struct __bit_shift_left {
0495   typedef _Tp __result_type;
0496   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x << __y; }
0497 };
0498 
0499 template <class _Tp>
0500 struct __bit_shift_right {
0501   typedef _Tp __result_type;
0502   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x >> __y; }
0503 };
0504 
0505 template <class _Tp, class _Fp>
0506 struct __apply_expr {
0507 private:
0508   _Fp __f_;
0509 
0510 public:
0511   typedef _Tp __result_type;
0512 
0513   _LIBCPP_HIDE_FROM_ABI explicit __apply_expr(_Fp __f) : __f_(__f) {}
0514 
0515   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return __f_(__x); }
0516 };
0517 
0518 template <class _Tp>
0519 struct __abs_expr {
0520   typedef _Tp __result_type;
0521   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::abs(__x); }
0522 };
0523 
0524 template <class _Tp>
0525 struct __acos_expr {
0526   typedef _Tp __result_type;
0527   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::acos(__x); }
0528 };
0529 
0530 template <class _Tp>
0531 struct __asin_expr {
0532   typedef _Tp __result_type;
0533   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::asin(__x); }
0534 };
0535 
0536 template <class _Tp>
0537 struct __atan_expr {
0538   typedef _Tp __result_type;
0539   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::atan(__x); }
0540 };
0541 
0542 template <class _Tp>
0543 struct __atan2_expr {
0544   typedef _Tp __result_type;
0545   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::atan2(__x, __y); }
0546 };
0547 
0548 template <class _Tp>
0549 struct __cos_expr {
0550   typedef _Tp __result_type;
0551   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cos(__x); }
0552 };
0553 
0554 template <class _Tp>
0555 struct __cosh_expr {
0556   typedef _Tp __result_type;
0557   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cosh(__x); }
0558 };
0559 
0560 template <class _Tp>
0561 struct __exp_expr {
0562   typedef _Tp __result_type;
0563   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::exp(__x); }
0564 };
0565 
0566 template <class _Tp>
0567 struct __log_expr {
0568   typedef _Tp __result_type;
0569   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log(__x); }
0570 };
0571 
0572 template <class _Tp>
0573 struct __log10_expr {
0574   typedef _Tp __result_type;
0575   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log10(__x); }
0576 };
0577 
0578 template <class _Tp>
0579 struct __pow_expr {
0580   typedef _Tp __result_type;
0581   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::pow(__x, __y); }
0582 };
0583 
0584 template <class _Tp>
0585 struct __sin_expr {
0586   typedef _Tp __result_type;
0587   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sin(__x); }
0588 };
0589 
0590 template <class _Tp>
0591 struct __sinh_expr {
0592   typedef _Tp __result_type;
0593   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sinh(__x); }
0594 };
0595 
0596 template <class _Tp>
0597 struct __sqrt_expr {
0598   typedef _Tp __result_type;
0599   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sqrt(__x); }
0600 };
0601 
0602 template <class _Tp>
0603 struct __tan_expr {
0604   typedef _Tp __result_type;
0605   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tan(__x); }
0606 };
0607 
0608 template <class _Tp>
0609 struct __tanh_expr {
0610   typedef _Tp __result_type;
0611   _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tanh(__x); }
0612 };
0613 
0614 template <class _ValExpr>
0615 class __slice_expr {
0616   typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
0617 
0618 public:
0619   typedef typename _RmExpr::value_type value_type;
0620   typedef value_type __result_type;
0621 
0622 private:
0623   _ValExpr __expr_;
0624   size_t __start_;
0625   size_t __size_;
0626   size_t __stride_;
0627 
0628   _LIBCPP_HIDE_FROM_ABI __slice_expr(const slice& __sl, const _RmExpr& __e)
0629       : __expr_(__e), __start_(__sl.start()), __size_(__sl.size()), __stride_(__sl.stride()) {}
0630 
0631 public:
0632   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__start_ + __i * __stride_]; }
0633 
0634   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
0635 
0636   template <class>
0637   friend class __val_expr;
0638   template <class>
0639   friend class _LIBCPP_TEMPLATE_VIS valarray;
0640 };
0641 
0642 template <class _ValExpr>
0643 class __mask_expr;
0644 
0645 template <class _ValExpr>
0646 class __indirect_expr;
0647 
0648 template <class _ValExpr>
0649 class __shift_expr {
0650   typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
0651 
0652 public:
0653   typedef typename _RmExpr::value_type value_type;
0654   typedef value_type __result_type;
0655 
0656 private:
0657   _ValExpr __expr_;
0658   size_t __size_;
0659   ptrdiff_t __ul_;
0660   ptrdiff_t __sn_;
0661   ptrdiff_t __n_;
0662   static const ptrdiff_t _Np = static_cast<ptrdiff_t>(sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
0663 
0664   _LIBCPP_HIDE_FROM_ABI __shift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()), __n_(__n) {
0665     ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
0666     __sn_             = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
0667     __ul_             = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
0668   }
0669 
0670 public:
0671   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __j) const {
0672     ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
0673     ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
0674     return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
0675   }
0676 
0677   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
0678 
0679   template <class>
0680   friend class __val_expr;
0681 };
0682 
0683 template <class _ValExpr>
0684 class __cshift_expr {
0685   typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
0686 
0687 public:
0688   typedef typename _RmExpr::value_type value_type;
0689   typedef value_type __result_type;
0690 
0691 private:
0692   _ValExpr __expr_;
0693   size_t __size_;
0694   size_t __m_;
0695   size_t __o1_;
0696   size_t __o2_;
0697 
0698   _LIBCPP_HIDE_FROM_ABI __cshift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()) {
0699     __n %= static_cast<int>(__size_);
0700     if (__n >= 0) {
0701       __m_  = __size_ - __n;
0702       __o1_ = __n;
0703       __o2_ = __n - __size_;
0704     } else {
0705       __m_  = -__n;
0706       __o1_ = __n + __size_;
0707       __o2_ = __n;
0708     }
0709   }
0710 
0711 public:
0712   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const {
0713     if (__i < __m_)
0714       return __expr_[__i + __o1_];
0715     return __expr_[__i + __o2_];
0716   }
0717 
0718   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
0719 
0720   template <class>
0721   friend class __val_expr;
0722 };
0723 
0724 template <class _ValExpr>
0725 class __val_expr;
0726 
0727 template <class _ValExpr>
0728 struct __is_val_expr : false_type {};
0729 
0730 template <class _ValExpr>
0731 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
0732 
0733 template <class _Tp>
0734 struct __is_val_expr<valarray<_Tp> > : true_type {};
0735 
0736 template <class _Tp>
0737 struct __is_val_expr<slice_array<_Tp> > : true_type {};
0738 
0739 template <class _Tp>
0740 struct __is_val_expr<gslice_array<_Tp> > : true_type {};
0741 
0742 template <class _Tp>
0743 struct __is_val_expr<mask_array<_Tp> > : true_type {};
0744 
0745 template <class _Tp>
0746 struct __is_val_expr<indirect_array<_Tp> > : true_type {};
0747 
0748 // The functions using a __val_expr access the elements by their index.
0749 // valarray and the libc++ lazy proxies have an operator[]. The
0750 // Standard proxy array's don't have this operator, instead they have a
0751 // implementation specific accessor
0752 //   __get(size_t)
0753 //
0754 // The functions use the non-member function
0755 //   __get(__val_expr, size_t)
0756 //
0757 // If the __val_expr is a specialization of __val_expr_use_member_functions it
0758 // uses the __val_expr's member function
0759 //   __get(size_t)
0760 // else it uses the __val_expr's member function
0761 //   operator[](size_t)
0762 template <class _ValExpr>
0763 struct __val_expr_use_member_functions;
0764 
0765 template <class>
0766 struct __val_expr_use_member_functions : false_type {};
0767 
0768 template <class _Tp>
0769 struct __val_expr_use_member_functions<slice_array<_Tp> > : true_type {};
0770 
0771 template <class _Tp>
0772 struct __val_expr_use_member_functions<gslice_array<_Tp> > : true_type {};
0773 
0774 template <class _Tp>
0775 struct __val_expr_use_member_functions<mask_array<_Tp> > : true_type {};
0776 
0777 template <class _Tp>
0778 struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {};
0779 
0780 template <class _Tp>
0781 class _LIBCPP_TEMPLATE_VIS valarray {
0782 public:
0783   typedef _Tp value_type;
0784   typedef _Tp __result_type;
0785 
0786 private:
0787   value_type* __begin_;
0788   value_type* __end_;
0789 
0790 public:
0791   // construct/destroy:
0792   _LIBCPP_HIDE_FROM_ABI valarray() : __begin_(nullptr), __end_(nullptr) {}
0793   inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit valarray(size_t __n);
0794   _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n);
0795   valarray(const value_type* __p, size_t __n);
0796   valarray(const valarray& __v);
0797 #ifndef _LIBCPP_CXX03_LANG
0798   _LIBCPP_HIDE_FROM_ABI valarray(valarray&& __v) _NOEXCEPT;
0799   valarray(initializer_list<value_type> __il);
0800 #endif // _LIBCPP_CXX03_LANG
0801   valarray(const slice_array<value_type>& __sa);
0802   valarray(const gslice_array<value_type>& __ga);
0803   valarray(const mask_array<value_type>& __ma);
0804   valarray(const indirect_array<value_type>& __ia);
0805   inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 ~valarray();
0806 
0807   // assignment:
0808   valarray& operator=(const valarray& __v);
0809 #ifndef _LIBCPP_CXX03_LANG
0810   _LIBCPP_HIDE_FROM_ABI valarray& operator=(valarray&& __v) _NOEXCEPT;
0811   _LIBCPP_HIDE_FROM_ABI valarray& operator=(initializer_list<value_type>);
0812 #endif // _LIBCPP_CXX03_LANG
0813   _LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x);
0814   _LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa);
0815   _LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga);
0816   _LIBCPP_HIDE_FROM_ABI valarray& operator=(const mask_array<value_type>& __ma);
0817   _LIBCPP_HIDE_FROM_ABI valarray& operator=(const indirect_array<value_type>& __ia);
0818   template <class _ValExpr>
0819   _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v);
0820 
0821   // element access:
0822   _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { return __begin_[__i]; }
0823 
0824   _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { return __begin_[__i]; }
0825 
0826   // subset operations:
0827   _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
0828   _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s);
0829   _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
0830   _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs);
0831 #ifndef _LIBCPP_CXX03_LANG
0832   _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
0833   _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs);
0834 #endif // _LIBCPP_CXX03_LANG
0835   _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
0836   _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb);
0837 #ifndef _LIBCPP_CXX03_LANG
0838   _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
0839   _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb);
0840 #endif // _LIBCPP_CXX03_LANG
0841   _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
0842   _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs);
0843 #ifndef _LIBCPP_CXX03_LANG
0844   _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
0845   _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs);
0846 #endif // _LIBCPP_CXX03_LANG
0847 
0848   // unary operators:
0849   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;
0850   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const;
0851   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const;
0852   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const;
0853 
0854   // computed assignment:
0855   _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const value_type& __x);
0856   _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const value_type& __x);
0857   _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const value_type& __x);
0858   _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const value_type& __x);
0859   _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const value_type& __x);
0860   _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const value_type& __x);
0861   _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const value_type& __x);
0862   _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const value_type& __x);
0863   _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const value_type& __x);
0864   _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const value_type& __x);
0865 
0866   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0867   _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const _Expr& __v);
0868 
0869   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0870   _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const _Expr& __v);
0871 
0872   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0873   _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const _Expr& __v);
0874 
0875   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0876   _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const _Expr& __v);
0877 
0878   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0879   _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const _Expr& __v);
0880 
0881   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0882   _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const _Expr& __v);
0883 
0884   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0885   _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const _Expr& __v);
0886 
0887   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0888   _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const _Expr& __v);
0889 
0890   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0891   _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const _Expr& __v);
0892 
0893   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
0894   _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const _Expr& __v);
0895 
0896   // member functions:
0897   _LIBCPP_HIDE_FROM_ABI void swap(valarray& __v) _NOEXCEPT;
0898 
0899   _LIBCPP_HIDE_FROM_ABI size_t size() const { return static_cast<size_t>(__end_ - __begin_); }
0900 
0901   _LIBCPP_HIDE_FROM_ABI value_type sum() const;
0902   _LIBCPP_HIDE_FROM_ABI value_type min() const;
0903   _LIBCPP_HIDE_FROM_ABI value_type max() const;
0904 
0905   valarray shift(int __i) const;
0906   valarray cshift(int __i) const;
0907   valarray apply(value_type __f(value_type)) const;
0908   valarray apply(value_type __f(const value_type&)) const;
0909   void resize(size_t __n, value_type __x = value_type());
0910 
0911 private:
0912   template <class>
0913   friend class _LIBCPP_TEMPLATE_VIS valarray;
0914   template <class>
0915   friend class _LIBCPP_TEMPLATE_VIS slice_array;
0916   template <class>
0917   friend class _LIBCPP_TEMPLATE_VIS gslice_array;
0918   template <class>
0919   friend class _LIBCPP_TEMPLATE_VIS mask_array;
0920   template <class>
0921   friend class __mask_expr;
0922   template <class>
0923   friend class _LIBCPP_TEMPLATE_VIS indirect_array;
0924   template <class>
0925   friend class __indirect_expr;
0926   template <class>
0927   friend class __val_expr;
0928 
0929   template <class _Up>
0930   friend _Up* begin(valarray<_Up>& __v);
0931 
0932   template <class _Up>
0933   friend const _Up* begin(const valarray<_Up>& __v);
0934 
0935   template <class _Up>
0936   friend _Up* end(valarray<_Up>& __v);
0937 
0938   template <class _Up>
0939   friend const _Up* end(const valarray<_Up>& __v);
0940 
0941   _LIBCPP_HIDE_FROM_ABI void __clear(size_t __capacity);
0942   valarray& __assign_range(const value_type* __f, const value_type* __l);
0943 };
0944 
0945 #if _LIBCPP_STD_VER >= 17
0946 template <class _Tp, size_t _Size>
0947 valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>;
0948 #endif
0949 
0950 template <class _Expr,
0951           __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0>
0952 _LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {
0953   return __v.__get(__i);
0954 }
0955 
0956 template <class _Expr,
0957           __enable_if_t<__is_val_expr<_Expr>::value && !__val_expr_use_member_functions<_Expr>::value, int> = 0>
0958 _LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {
0959   return __v[__i];
0960 }
0961 
0962 extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t);
0963 
0964 template <class _Op, class _Tp>
0965 struct _UnaryOp<_Op, valarray<_Tp> > {
0966   typedef typename _Op::__result_type __result_type;
0967   using value_type = __decay_t<__result_type>;
0968 
0969   _Op __op_;
0970   const valarray<_Tp>& __a0_;
0971 
0972   _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
0973 
0974   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); }
0975 
0976   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
0977 };
0978 
0979 template <class _Op, class _Tp, class _A1>
0980 struct _BinaryOp<_Op, valarray<_Tp>, _A1> {
0981   typedef typename _Op::__result_type __result_type;
0982   using value_type = __decay_t<__result_type>;
0983 
0984   _Op __op_;
0985   const valarray<_Tp>& __a0_;
0986   _A1 __a1_;
0987 
0988   _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
0989       : __op_(__op), __a0_(__a0), __a1_(__a1) {}
0990 
0991   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }
0992 
0993   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
0994 };
0995 
0996 template <class _Op, class _A0, class _Tp>
0997 struct _BinaryOp<_Op, _A0, valarray<_Tp> > {
0998   typedef typename _Op::__result_type __result_type;
0999   using value_type = __decay_t<__result_type>;
1000 
1001   _Op __op_;
1002   _A0 __a0_;
1003   const valarray<_Tp>& __a1_;
1004 
1005   _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1006       : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1007 
1008   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }
1009 
1010   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
1011 };
1012 
1013 template <class _Op, class _Tp>
1014 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > {
1015   typedef typename _Op::__result_type __result_type;
1016   using value_type = __decay_t<__result_type>;
1017 
1018   _Op __op_;
1019   const valarray<_Tp>& __a0_;
1020   const valarray<_Tp>& __a1_;
1021 
1022   _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1023       : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1024 
1025   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }
1026 
1027   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }
1028 };
1029 
1030 // slice_array
1031 
1032 template <class _Tp>
1033 class _LIBCPP_TEMPLATE_VIS slice_array {
1034 public:
1035   typedef _Tp value_type;
1036 
1037 private:
1038   value_type* __vp_;
1039   size_t __size_;
1040   size_t __stride_;
1041 
1042 public:
1043   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1044   void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;
1045 
1046   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1047   void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;
1048 
1049   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1050   void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;
1051 
1052   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1053   void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;
1054 
1055   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1056   void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;
1057 
1058   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1059   void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;
1060 
1061   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1062   void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;
1063 
1064   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1065   void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;
1066 
1067   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1068   void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;
1069 
1070   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1071   void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;
1072 
1073   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1074   void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;
1075 
1076   slice_array(slice_array const&) = default;
1077 
1078   _LIBCPP_HIDE_FROM_ABI const slice_array& operator=(const slice_array& __sa) const;
1079 
1080   _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
1081 
1082   _LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const;
1083 
1084   // Behaves like __val_expr::operator[], which returns by value.
1085   _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1086     _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "slice_array.__get() index out of bounds");
1087     return __vp_[__i * __stride_];
1088   }
1089 
1090 private:
1091   _LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v)
1092       : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {}
1093 
1094   template <class>
1095   friend class valarray;
1096 };
1097 
1098 template <class _Tp>
1099 inline const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const {
1100   value_type* __t       = __vp_;
1101   const value_type* __s = __sa.__vp_;
1102   for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1103     *__t = *__s;
1104   return *this;
1105 }
1106 
1107 template <class _Tp>
1108 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1109 inline void slice_array<_Tp>::operator=(const _Expr& __v) const {
1110   value_type* __t = __vp_;
1111   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1112     *__t = __v[__i];
1113 }
1114 
1115 template <class _Tp>
1116 inline void slice_array<_Tp>::operator=(const valarray<value_type>& __va) const {
1117   value_type* __t = __vp_;
1118   for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)
1119     *__t = __va[__i];
1120 }
1121 
1122 template <class _Tp>
1123 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1124 inline void slice_array<_Tp>::operator*=(const _Expr& __v) const {
1125   value_type* __t = __vp_;
1126   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1127     *__t *= __v[__i];
1128 }
1129 
1130 template <class _Tp>
1131 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1132 inline void slice_array<_Tp>::operator/=(const _Expr& __v) const {
1133   value_type* __t = __vp_;
1134   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1135     *__t /= __v[__i];
1136 }
1137 
1138 template <class _Tp>
1139 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1140 inline void slice_array<_Tp>::operator%=(const _Expr& __v) const {
1141   value_type* __t = __vp_;
1142   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1143     *__t %= __v[__i];
1144 }
1145 
1146 template <class _Tp>
1147 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1148 inline void slice_array<_Tp>::operator+=(const _Expr& __v) const {
1149   value_type* __t = __vp_;
1150   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1151     *__t += __v[__i];
1152 }
1153 
1154 template <class _Tp>
1155 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1156 inline void slice_array<_Tp>::operator-=(const _Expr& __v) const {
1157   value_type* __t = __vp_;
1158   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1159     *__t -= __v[__i];
1160 }
1161 
1162 template <class _Tp>
1163 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1164 inline void slice_array<_Tp>::operator^=(const _Expr& __v) const {
1165   value_type* __t = __vp_;
1166   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1167     *__t ^= __v[__i];
1168 }
1169 
1170 template <class _Tp>
1171 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1172 inline void slice_array<_Tp>::operator&=(const _Expr& __v) const {
1173   value_type* __t = __vp_;
1174   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1175     *__t &= __v[__i];
1176 }
1177 
1178 template <class _Tp>
1179 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1180 inline void slice_array<_Tp>::operator|=(const _Expr& __v) const {
1181   value_type* __t = __vp_;
1182   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1183     *__t |= __v[__i];
1184 }
1185 
1186 template <class _Tp>
1187 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1188 inline void slice_array<_Tp>::operator<<=(const _Expr& __v) const {
1189   value_type* __t = __vp_;
1190   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1191     *__t <<= __v[__i];
1192 }
1193 
1194 template <class _Tp>
1195 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1196 inline void slice_array<_Tp>::operator>>=(const _Expr& __v) const {
1197   value_type* __t = __vp_;
1198   for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1199     *__t >>= __v[__i];
1200 }
1201 
1202 template <class _Tp>
1203 inline void slice_array<_Tp>::operator=(const value_type& __x) const {
1204   value_type* __t = __vp_;
1205   for (size_t __n = __size_; __n; --__n, __t += __stride_)
1206     *__t = __x;
1207 }
1208 
1209 // gslice
1210 
1211 class _LIBCPP_EXPORTED_FROM_ABI gslice {
1212   valarray<size_t> __size_;
1213   valarray<size_t> __stride_;
1214   valarray<size_t> __1d_;
1215 
1216 public:
1217   _LIBCPP_HIDE_FROM_ABI gslice() {}
1218 
1219   _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, const valarray<size_t>& __stride)
1220       : __size_(__size), __stride_(__stride) {
1221     __init(__start);
1222   }
1223 
1224 #ifndef _LIBCPP_CXX03_LANG
1225 
1226   _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, valarray<size_t>&& __stride)
1227       : __size_(__size), __stride_(std::move(__stride)) {
1228     __init(__start);
1229   }
1230 
1231   _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, valarray<size_t>&& __size, const valarray<size_t>& __stride)
1232       : __size_(std::move(__size)), __stride_(__stride) {
1233     __init(__start);
1234   }
1235 
1236   _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, valarray<size_t>&& __size, valarray<size_t>&& __stride)
1237       : __size_(std::move(__size)), __stride_(std::move(__stride)) {
1238     __init(__start);
1239   }
1240 
1241 #endif // _LIBCPP_CXX03_LANG
1242 
1243   _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; }
1244 
1245   _LIBCPP_HIDE_FROM_ABI valarray<size_t> size() const { return __size_; }
1246 
1247   _LIBCPP_HIDE_FROM_ABI valarray<size_t> stride() const { return __stride_; }
1248 
1249 private:
1250   void __init(size_t __start);
1251 
1252   template <class>
1253   friend class gslice_array;
1254   template <class>
1255   friend class valarray;
1256   template <class>
1257   friend class __val_expr;
1258 };
1259 
1260 // gslice_array
1261 
1262 template <class _Tp>
1263 class _LIBCPP_TEMPLATE_VIS gslice_array {
1264 public:
1265   typedef _Tp value_type;
1266 
1267 private:
1268   value_type* __vp_;
1269   valarray<size_t> __1d_;
1270 
1271 public:
1272   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1273   void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;
1274 
1275   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1276   void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;
1277 
1278   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1279   void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;
1280 
1281   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1282   void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;
1283 
1284   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1285   void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;
1286 
1287   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1288   void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;
1289 
1290   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1291   void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;
1292 
1293   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1294   void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;
1295 
1296   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1297   void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;
1298 
1299   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1300   void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;
1301 
1302   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1303   void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;
1304 
1305   _LIBCPP_HIDE_FROM_ABI const gslice_array& operator=(const gslice_array& __ga) const;
1306 
1307   _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
1308 
1309   gslice_array(const gslice_array&) = default;
1310 
1311   // Behaves like __val_expr::operator[], which returns by value.
1312   _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1313     _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "gslice_array.__get() index out of bounds");
1314     return __vp_[__1d_[__i]];
1315   }
1316 
1317 private:
1318   gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1319       : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {}
1320 
1321 #ifndef _LIBCPP_CXX03_LANG
1322   gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1323       : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__gs.__1d_)) {}
1324 #endif // _LIBCPP_CXX03_LANG
1325 
1326   template <class>
1327   friend class valarray;
1328 };
1329 
1330 template <class _Tp>
1331 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1332 inline void gslice_array<_Tp>::operator=(const _Expr& __v) const {
1333   typedef const size_t* _Ip;
1334   size_t __j = 0;
1335   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1336     __vp_[*__i] = __v[__j];
1337 }
1338 
1339 template <class _Tp>
1340 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1341 inline void gslice_array<_Tp>::operator*=(const _Expr& __v) const {
1342   typedef const size_t* _Ip;
1343   size_t __j = 0;
1344   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1345     __vp_[*__i] *= __v[__j];
1346 }
1347 
1348 template <class _Tp>
1349 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1350 inline void gslice_array<_Tp>::operator/=(const _Expr& __v) const {
1351   typedef const size_t* _Ip;
1352   size_t __j = 0;
1353   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1354     __vp_[*__i] /= __v[__j];
1355 }
1356 
1357 template <class _Tp>
1358 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1359 inline void gslice_array<_Tp>::operator%=(const _Expr& __v) const {
1360   typedef const size_t* _Ip;
1361   size_t __j = 0;
1362   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1363     __vp_[*__i] %= __v[__j];
1364 }
1365 
1366 template <class _Tp>
1367 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1368 inline void gslice_array<_Tp>::operator+=(const _Expr& __v) const {
1369   typedef const size_t* _Ip;
1370   size_t __j = 0;
1371   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1372     __vp_[*__i] += __v[__j];
1373 }
1374 
1375 template <class _Tp>
1376 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1377 inline void gslice_array<_Tp>::operator-=(const _Expr& __v) const {
1378   typedef const size_t* _Ip;
1379   size_t __j = 0;
1380   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1381     __vp_[*__i] -= __v[__j];
1382 }
1383 
1384 template <class _Tp>
1385 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1386 inline void gslice_array<_Tp>::operator^=(const _Expr& __v) const {
1387   typedef const size_t* _Ip;
1388   size_t __j = 0;
1389   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1390     __vp_[*__i] ^= __v[__j];
1391 }
1392 
1393 template <class _Tp>
1394 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1395 inline void gslice_array<_Tp>::operator&=(const _Expr& __v) const {
1396   typedef const size_t* _Ip;
1397   size_t __j = 0;
1398   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1399     __vp_[*__i] &= __v[__j];
1400 }
1401 
1402 template <class _Tp>
1403 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1404 inline void gslice_array<_Tp>::operator|=(const _Expr& __v) const {
1405   typedef const size_t* _Ip;
1406   size_t __j = 0;
1407   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1408     __vp_[*__i] |= __v[__j];
1409 }
1410 
1411 template <class _Tp>
1412 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1413 inline void gslice_array<_Tp>::operator<<=(const _Expr& __v) const {
1414   typedef const size_t* _Ip;
1415   size_t __j = 0;
1416   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1417     __vp_[*__i] <<= __v[__j];
1418 }
1419 
1420 template <class _Tp>
1421 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1422 inline void gslice_array<_Tp>::operator>>=(const _Expr& __v) const {
1423   typedef const size_t* _Ip;
1424   size_t __j = 0;
1425   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1426     __vp_[*__i] >>= __v[__j];
1427 }
1428 
1429 template <class _Tp>
1430 inline const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const {
1431   typedef const size_t* _Ip;
1432   const value_type* __s = __ga.__vp_;
1433   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; __i != __e; ++__i, ++__j)
1434     __vp_[*__i] = __s[*__j];
1435   return *this;
1436 }
1437 
1438 template <class _Tp>
1439 inline void gslice_array<_Tp>::operator=(const value_type& __x) const {
1440   typedef const size_t* _Ip;
1441   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1442     __vp_[*__i] = __x;
1443 }
1444 
1445 // mask_array
1446 
1447 template <class _Tp>
1448 class _LIBCPP_TEMPLATE_VIS mask_array {
1449 public:
1450   typedef _Tp value_type;
1451 
1452 private:
1453   value_type* __vp_;
1454   valarray<size_t> __1d_;
1455 
1456 public:
1457   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1458   void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;
1459 
1460   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1461   void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;
1462 
1463   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1464   void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;
1465 
1466   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1467   void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;
1468 
1469   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1470   void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;
1471 
1472   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1473   void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;
1474 
1475   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1476   void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;
1477 
1478   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1479   void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;
1480 
1481   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1482   void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;
1483 
1484   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1485   void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;
1486 
1487   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1488   void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;
1489 
1490   mask_array(const mask_array&) = default;
1491 
1492   _LIBCPP_HIDE_FROM_ABI const mask_array& operator=(const mask_array& __ma) const;
1493 
1494   _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
1495 
1496   // Behaves like __val_expr::operator[], which returns by value.
1497   _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1498     _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "mask_array.__get() index out of bounds");
1499     return __vp_[__1d_[__i]];
1500   }
1501 
1502 private:
1503   _LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1504       : __vp_(const_cast<value_type*>(__v.__begin_)),
1505         __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) {
1506     size_t __j = 0;
1507     for (size_t __i = 0; __i < __vb.size(); ++__i)
1508       if (__vb[__i])
1509         __1d_[__j++] = __i;
1510   }
1511 
1512   template <class>
1513   friend class valarray;
1514 };
1515 
1516 template <class _Tp>
1517 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1518 inline void mask_array<_Tp>::operator=(const _Expr& __v) const {
1519   size_t __n = __1d_.size();
1520   for (size_t __i = 0; __i < __n; ++__i)
1521     __vp_[__1d_[__i]] = __v[__i];
1522 }
1523 
1524 template <class _Tp>
1525 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1526 inline void mask_array<_Tp>::operator*=(const _Expr& __v) const {
1527   size_t __n = __1d_.size();
1528   for (size_t __i = 0; __i < __n; ++__i)
1529     __vp_[__1d_[__i]] *= __v[__i];
1530 }
1531 
1532 template <class _Tp>
1533 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1534 inline void mask_array<_Tp>::operator/=(const _Expr& __v) const {
1535   size_t __n = __1d_.size();
1536   for (size_t __i = 0; __i < __n; ++__i)
1537     __vp_[__1d_[__i]] /= __v[__i];
1538 }
1539 
1540 template <class _Tp>
1541 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1542 inline void mask_array<_Tp>::operator%=(const _Expr& __v) const {
1543   size_t __n = __1d_.size();
1544   for (size_t __i = 0; __i < __n; ++__i)
1545     __vp_[__1d_[__i]] %= __v[__i];
1546 }
1547 
1548 template <class _Tp>
1549 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1550 inline void mask_array<_Tp>::operator+=(const _Expr& __v) const {
1551   size_t __n = __1d_.size();
1552   for (size_t __i = 0; __i < __n; ++__i)
1553     __vp_[__1d_[__i]] += __v[__i];
1554 }
1555 
1556 template <class _Tp>
1557 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1558 inline void mask_array<_Tp>::operator-=(const _Expr& __v) const {
1559   size_t __n = __1d_.size();
1560   for (size_t __i = 0; __i < __n; ++__i)
1561     __vp_[__1d_[__i]] -= __v[__i];
1562 }
1563 
1564 template <class _Tp>
1565 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1566 inline void mask_array<_Tp>::operator^=(const _Expr& __v) const {
1567   size_t __n = __1d_.size();
1568   for (size_t __i = 0; __i < __n; ++__i)
1569     __vp_[__1d_[__i]] ^= __v[__i];
1570 }
1571 
1572 template <class _Tp>
1573 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1574 inline void mask_array<_Tp>::operator&=(const _Expr& __v) const {
1575   size_t __n = __1d_.size();
1576   for (size_t __i = 0; __i < __n; ++__i)
1577     __vp_[__1d_[__i]] &= __v[__i];
1578 }
1579 
1580 template <class _Tp>
1581 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1582 inline void mask_array<_Tp>::operator|=(const _Expr& __v) const {
1583   size_t __n = __1d_.size();
1584   for (size_t __i = 0; __i < __n; ++__i)
1585     __vp_[__1d_[__i]] |= __v[__i];
1586 }
1587 
1588 template <class _Tp>
1589 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1590 inline void mask_array<_Tp>::operator<<=(const _Expr& __v) const {
1591   size_t __n = __1d_.size();
1592   for (size_t __i = 0; __i < __n; ++__i)
1593     __vp_[__1d_[__i]] <<= __v[__i];
1594 }
1595 
1596 template <class _Tp>
1597 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1598 inline void mask_array<_Tp>::operator>>=(const _Expr& __v) const {
1599   size_t __n = __1d_.size();
1600   for (size_t __i = 0; __i < __n; ++__i)
1601     __vp_[__1d_[__i]] >>= __v[__i];
1602 }
1603 
1604 template <class _Tp>
1605 inline const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const {
1606   size_t __n = __1d_.size();
1607   for (size_t __i = 0; __i < __n; ++__i)
1608     __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
1609   return *this;
1610 }
1611 
1612 template <class _Tp>
1613 inline void mask_array<_Tp>::operator=(const value_type& __x) const {
1614   size_t __n = __1d_.size();
1615   for (size_t __i = 0; __i < __n; ++__i)
1616     __vp_[__1d_[__i]] = __x;
1617 }
1618 
1619 template <class _ValExpr>
1620 class __mask_expr {
1621   typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
1622 
1623 public:
1624   typedef typename _RmExpr::value_type value_type;
1625   typedef value_type __result_type;
1626 
1627 private:
1628   _ValExpr __expr_;
1629   valarray<size_t> __1d_;
1630 
1631   _LIBCPP_HIDE_FROM_ABI __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
1632       : __expr_(__e), __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) {
1633     size_t __j = 0;
1634     for (size_t __i = 0; __i < __vb.size(); ++__i)
1635       if (__vb[__i])
1636         __1d_[__j++] = __i;
1637   }
1638 
1639 public:
1640   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }
1641 
1642   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); }
1643 
1644   template <class>
1645   friend class __val_expr;
1646   template <class>
1647   friend class valarray;
1648 };
1649 
1650 // indirect_array
1651 
1652 template <class _Tp>
1653 class _LIBCPP_TEMPLATE_VIS indirect_array {
1654 public:
1655   typedef _Tp value_type;
1656 
1657 private:
1658   value_type* __vp_;
1659   valarray<size_t> __1d_;
1660 
1661 public:
1662   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1663   void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;
1664 
1665   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1666   void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;
1667 
1668   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1669   void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;
1670 
1671   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1672   void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;
1673 
1674   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1675   void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;
1676 
1677   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1678   void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;
1679 
1680   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1681   void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;
1682 
1683   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1684   void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;
1685 
1686   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1687   void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;
1688 
1689   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1690   void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;
1691 
1692   template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
1693   void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;
1694 
1695   indirect_array(const indirect_array&) = default;
1696 
1697   _LIBCPP_HIDE_FROM_ABI const indirect_array& operator=(const indirect_array& __ia) const;
1698 
1699   _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
1700 
1701   // Behaves like __val_expr::operator[], which returns by value.
1702   _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1703     _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "indirect_array.__get() index out of bounds");
1704     return __vp_[__1d_[__i]];
1705   }
1706 
1707 private:
1708   _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
1709       : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {}
1710 
1711 #ifndef _LIBCPP_CXX03_LANG
1712 
1713   _LIBCPP_HIDE_FROM_ABI indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
1714       : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__ia)) {}
1715 
1716 #endif // _LIBCPP_CXX03_LANG
1717 
1718   template <class>
1719   friend class valarray;
1720 };
1721 
1722 template <class _Tp>
1723 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1724 inline void indirect_array<_Tp>::operator=(const _Expr& __v) const {
1725   size_t __n = __1d_.size();
1726   for (size_t __i = 0; __i < __n; ++__i)
1727     __vp_[__1d_[__i]] = __v[__i];
1728 }
1729 
1730 template <class _Tp>
1731 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1732 inline void indirect_array<_Tp>::operator*=(const _Expr& __v) const {
1733   size_t __n = __1d_.size();
1734   for (size_t __i = 0; __i < __n; ++__i)
1735     __vp_[__1d_[__i]] *= __v[__i];
1736 }
1737 
1738 template <class _Tp>
1739 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1740 inline void indirect_array<_Tp>::operator/=(const _Expr& __v) const {
1741   size_t __n = __1d_.size();
1742   for (size_t __i = 0; __i < __n; ++__i)
1743     __vp_[__1d_[__i]] /= __v[__i];
1744 }
1745 
1746 template <class _Tp>
1747 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1748 inline void indirect_array<_Tp>::operator%=(const _Expr& __v) const {
1749   size_t __n = __1d_.size();
1750   for (size_t __i = 0; __i < __n; ++__i)
1751     __vp_[__1d_[__i]] %= __v[__i];
1752 }
1753 
1754 template <class _Tp>
1755 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1756 inline void indirect_array<_Tp>::operator+=(const _Expr& __v) const {
1757   size_t __n = __1d_.size();
1758   for (size_t __i = 0; __i < __n; ++__i)
1759     __vp_[__1d_[__i]] += __v[__i];
1760 }
1761 
1762 template <class _Tp>
1763 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1764 inline void indirect_array<_Tp>::operator-=(const _Expr& __v) const {
1765   size_t __n = __1d_.size();
1766   for (size_t __i = 0; __i < __n; ++__i)
1767     __vp_[__1d_[__i]] -= __v[__i];
1768 }
1769 
1770 template <class _Tp>
1771 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1772 inline void indirect_array<_Tp>::operator^=(const _Expr& __v) const {
1773   size_t __n = __1d_.size();
1774   for (size_t __i = 0; __i < __n; ++__i)
1775     __vp_[__1d_[__i]] ^= __v[__i];
1776 }
1777 
1778 template <class _Tp>
1779 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1780 inline void indirect_array<_Tp>::operator&=(const _Expr& __v) const {
1781   size_t __n = __1d_.size();
1782   for (size_t __i = 0; __i < __n; ++__i)
1783     __vp_[__1d_[__i]] &= __v[__i];
1784 }
1785 
1786 template <class _Tp>
1787 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1788 inline void indirect_array<_Tp>::operator|=(const _Expr& __v) const {
1789   size_t __n = __1d_.size();
1790   for (size_t __i = 0; __i < __n; ++__i)
1791     __vp_[__1d_[__i]] |= __v[__i];
1792 }
1793 
1794 template <class _Tp>
1795 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1796 inline void indirect_array<_Tp>::operator<<=(const _Expr& __v) const {
1797   size_t __n = __1d_.size();
1798   for (size_t __i = 0; __i < __n; ++__i)
1799     __vp_[__1d_[__i]] <<= __v[__i];
1800 }
1801 
1802 template <class _Tp>
1803 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
1804 inline void indirect_array<_Tp>::operator>>=(const _Expr& __v) const {
1805   size_t __n = __1d_.size();
1806   for (size_t __i = 0; __i < __n; ++__i)
1807     __vp_[__1d_[__i]] >>= __v[__i];
1808 }
1809 
1810 template <class _Tp>
1811 inline const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const {
1812   typedef const size_t* _Ip;
1813   const value_type* __s = __ia.__vp_;
1814   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; __i != __e; ++__i, ++__j)
1815     __vp_[*__i] = __s[*__j];
1816   return *this;
1817 }
1818 
1819 template <class _Tp>
1820 inline void indirect_array<_Tp>::operator=(const value_type& __x) const {
1821   typedef const size_t* _Ip;
1822   for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1823     __vp_[*__i] = __x;
1824 }
1825 
1826 template <class _ValExpr>
1827 class __indirect_expr {
1828   typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
1829 
1830 public:
1831   typedef typename _RmExpr::value_type value_type;
1832   typedef value_type __result_type;
1833 
1834 private:
1835   _ValExpr __expr_;
1836   valarray<size_t> __1d_;
1837 
1838   _LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {}
1839 
1840 #ifndef _LIBCPP_CXX03_LANG
1841 
1842   _LIBCPP_HIDE_FROM_ABI __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
1843       : __expr_(__e), __1d_(std::move(__ia)) {}
1844 
1845 #endif // _LIBCPP_CXX03_LANG
1846 
1847 public:
1848   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }
1849 
1850   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); }
1851 
1852   template <class>
1853   friend class __val_expr;
1854   template <class>
1855   friend class _LIBCPP_TEMPLATE_VIS valarray;
1856 };
1857 
1858 template <class _ValExpr>
1859 class __val_expr {
1860   typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
1861 
1862   _ValExpr __expr_;
1863 
1864 public:
1865   typedef typename _RmExpr::value_type value_type;
1866   typedef typename _RmExpr::__result_type __result_type;
1867 
1868   _LIBCPP_HIDE_FROM_ABI explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
1869 
1870   _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__i]; }
1871 
1872   _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const {
1873     typedef __slice_expr<_ValExpr> _NewExpr;
1874     return __val_expr< _NewExpr >(_NewExpr(__s, __expr_));
1875   }
1876 
1877   _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const {
1878     typedef __indirect_expr<_ValExpr> _NewExpr;
1879     return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_));
1880   }
1881 
1882   _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const {
1883     typedef __mask_expr<_ValExpr> _NewExpr;
1884     return __val_expr< _NewExpr >(_NewExpr(__vb, __expr_));
1885   }
1886 
1887   _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const {
1888     typedef __indirect_expr<_ValExpr> _NewExpr;
1889     return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_));
1890   }
1891 
1892   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > operator+() const {
1893     typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
1894     return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
1895   }
1896 
1897   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > operator-() const {
1898     typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
1899     return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
1900   }
1901 
1902   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > operator~() const {
1903     typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
1904     return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
1905   }
1906 
1907   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > operator!() const {
1908     typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
1909     return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
1910   }
1911 
1912   operator valarray<__result_type>() const;
1913 
1914   _LIBCPP_HIDE_FROM_ABI size_t size() const { return __expr_.size(); }
1915 
1916   _LIBCPP_HIDE_FROM_ABI __result_type sum() const {
1917     size_t __n        = __expr_.size();
1918     __result_type __r = __n ? __expr_[0] : __result_type();
1919     for (size_t __i = 1; __i < __n; ++__i)
1920       __r += __expr_[__i];
1921     return __r;
1922   }
1923 
1924   _LIBCPP_HIDE_FROM_ABI __result_type min() const {
1925     size_t __n        = size();
1926     __result_type __r = __n ? (*this)[0] : __result_type();
1927     for (size_t __i = 1; __i < __n; ++__i) {
1928       __result_type __x = __expr_[__i];
1929       if (__x < __r)
1930         __r = __x;
1931     }
1932     return __r;
1933   }
1934 
1935   _LIBCPP_HIDE_FROM_ABI __result_type max() const {
1936     size_t __n        = size();
1937     __result_type __r = __n ? (*this)[0] : __result_type();
1938     for (size_t __i = 1; __i < __n; ++__i) {
1939       __result_type __x = __expr_[__i];
1940       if (__r < __x)
1941         __r = __x;
1942     }
1943     return __r;
1944   }
1945 
1946   _LIBCPP_HIDE_FROM_ABI __val_expr<__shift_expr<_ValExpr> > shift(int __i) const {
1947     return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));
1948   }
1949 
1950   _LIBCPP_HIDE_FROM_ABI __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const {
1951     return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));
1952   }
1953 
1954   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(value_type)>, _ValExpr> >
1955   apply(value_type __f(value_type)) const {
1956     typedef __apply_expr<value_type, value_type (*)(value_type)> _Op;
1957     typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
1958     return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
1959   }
1960 
1961   _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(const value_type&)>, _ValExpr> >
1962   apply(value_type __f(const value_type&)) const {
1963     typedef __apply_expr<value_type, value_type (*)(const value_type&)> _Op;
1964     typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
1965     return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
1966   }
1967 };
1968 
1969 template <class _ValExpr>
1970 __val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const {
1971   valarray<__result_type> __r;
1972   size_t __n = __expr_.size();
1973   if (__n) {
1974     __r.__begin_ = __r.__end_ = allocator<__result_type>().allocate(__n);
1975     for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
1976       ::new ((void*)__r.__end_) __result_type(__expr_[__i]);
1977   }
1978   return __r;
1979 }
1980 
1981 // valarray
1982 
1983 template <class _Tp>
1984 inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) {
1985   if (__n) {
1986     __begin_ = __end_ = allocator<value_type>().allocate(__n);
1987 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1988     try {
1989 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
1990       for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
1991         ::new ((void*)__end_) value_type();
1992 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1993     } catch (...) {
1994       __clear(__n);
1995       throw;
1996     }
1997 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
1998   }
1999 }
2000 
2001 template <class _Tp>
2002 inline valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(nullptr), __end_(nullptr) {
2003   resize(__n, __x);
2004 }
2005 
2006 template <class _Tp>
2007 valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) {
2008   if (__n) {
2009     __begin_ = __end_ = allocator<value_type>().allocate(__n);
2010 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2011     try {
2012 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2013       for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
2014         ::new ((void*)__end_) value_type(*__p);
2015 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2016     } catch (...) {
2017       __clear(__n);
2018       throw;
2019     }
2020 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2021   }
2022 }
2023 
2024 template <class _Tp>
2025 valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) {
2026   if (__v.size()) {
2027     __begin_ = __end_ = allocator<value_type>().allocate(__v.size());
2028 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2029     try {
2030 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2031       for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2032         ::new ((void*)__end_) value_type(*__p);
2033 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2034     } catch (...) {
2035       __clear(__v.size());
2036       throw;
2037     }
2038 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2039   }
2040 }
2041 
2042 #ifndef _LIBCPP_CXX03_LANG
2043 
2044 template <class _Tp>
2045 inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) {
2046   __v.__begin_ = __v.__end_ = nullptr;
2047 }
2048 
2049 template <class _Tp>
2050 valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr), __end_(nullptr) {
2051   const size_t __n = __il.size();
2052   if (__n) {
2053     __begin_ = __end_ = allocator<value_type>().allocate(__n);
2054 #  ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2055     try {
2056 #  endif // _LIBCPP_HAS_NO_EXCEPTIONS
2057       size_t __n_left = __n;
2058       for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
2059         ::new ((void*)__end_) value_type(*__p);
2060 #  ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2061     } catch (...) {
2062       __clear(__n);
2063       throw;
2064     }
2065 #  endif // _LIBCPP_HAS_NO_EXCEPTIONS
2066   }
2067 }
2068 
2069 #endif // _LIBCPP_CXX03_LANG
2070 
2071 template <class _Tp>
2072 valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) {
2073   const size_t __n = __sa.__size_;
2074   if (__n) {
2075     __begin_ = __end_ = allocator<value_type>().allocate(__n);
2076 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2077     try {
2078 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2079       size_t __n_left = __n;
2080       for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
2081         ::new ((void*)__end_) value_type(*__p);
2082 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2083     } catch (...) {
2084       __clear(__n);
2085       throw;
2086     }
2087 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2088   }
2089 }
2090 
2091 template <class _Tp>
2092 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr), __end_(nullptr) {
2093   const size_t __n = __ga.__1d_.size();
2094   if (__n) {
2095     __begin_ = __end_ = allocator<value_type>().allocate(__n);
2096 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2097     try {
2098 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2099       typedef const size_t* _Ip;
2100       const value_type* __s = __ga.__vp_;
2101       for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_)
2102         ::new ((void*)__end_) value_type(__s[*__i]);
2103 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2104     } catch (...) {
2105       __clear(__n);
2106       throw;
2107     }
2108 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2109   }
2110 }
2111 
2112 template <class _Tp>
2113 valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), __end_(nullptr) {
2114   const size_t __n = __ma.__1d_.size();
2115   if (__n) {
2116     __begin_ = __end_ = allocator<value_type>().allocate(__n);
2117 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2118     try {
2119 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2120       typedef const size_t* _Ip;
2121       const value_type* __s = __ma.__vp_;
2122       for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_)
2123         ::new ((void*)__end_) value_type(__s[*__i]);
2124 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2125     } catch (...) {
2126       __clear(__n);
2127       throw;
2128     }
2129 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2130   }
2131 }
2132 
2133 template <class _Tp>
2134 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullptr), __end_(nullptr) {
2135   const size_t __n = __ia.__1d_.size();
2136   if (__n) {
2137     __begin_ = __end_ = allocator<value_type>().allocate(__n);
2138 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2139     try {
2140 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2141       typedef const size_t* _Ip;
2142       const value_type* __s = __ia.__vp_;
2143       for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_)
2144         ::new ((void*)__end_) value_type(__s[*__i]);
2145 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2146     } catch (...) {
2147       __clear(__n);
2148       throw;
2149     }
2150 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2151   }
2152 }
2153 
2154 template <class _Tp>
2155 inline valarray<_Tp>::~valarray() {
2156   __clear(size());
2157 }
2158 
2159 template <class _Tp>
2160 valarray<_Tp>& valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) {
2161   size_t __n = __l - __f;
2162   if (size() != __n) {
2163     __clear(size());
2164     __begin_ = allocator<value_type>().allocate(__n);
2165     __end_   = __begin_ + __n;
2166     std::uninitialized_copy(__f, __l, __begin_);
2167   } else {
2168     std::copy(__f, __l, __begin_);
2169   }
2170   return *this;
2171 }
2172 
2173 template <class _Tp>
2174 valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) {
2175   if (this != std::addressof(__v))
2176     return __assign_range(__v.__begin_, __v.__end_);
2177   return *this;
2178 }
2179 
2180 #ifndef _LIBCPP_CXX03_LANG
2181 
2182 template <class _Tp>
2183 inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT {
2184   __clear(size());
2185   __begin_     = __v.__begin_;
2186   __end_       = __v.__end_;
2187   __v.__begin_ = nullptr;
2188   __v.__end_   = nullptr;
2189   return *this;
2190 }
2191 
2192 template <class _Tp>
2193 inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list<value_type> __il) {
2194   return __assign_range(__il.begin(), __il.end());
2195 }
2196 
2197 #endif // _LIBCPP_CXX03_LANG
2198 
2199 template <class _Tp>
2200 inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) {
2201   std::fill(__begin_, __end_, __x);
2202   return *this;
2203 }
2204 
2205 template <class _Tp>
2206 inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<value_type>& __sa) {
2207   value_type* __t       = __begin_;
2208   const value_type* __s = __sa.__vp_;
2209   for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
2210     *__t = *__s;
2211   return *this;
2212 }
2213 
2214 template <class _Tp>
2215 inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) {
2216   typedef const size_t* _Ip;
2217   value_type* __t       = __begin_;
2218   const value_type* __s = __ga.__vp_;
2219   for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__t)
2220     *__t = __s[*__i];
2221   return *this;
2222 }
2223 
2224 template <class _Tp>
2225 inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<value_type>& __ma) {
2226   typedef const size_t* _Ip;
2227   value_type* __t       = __begin_;
2228   const value_type* __s = __ma.__vp_;
2229   for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__t)
2230     *__t = __s[*__i];
2231   return *this;
2232 }
2233 
2234 template <class _Tp>
2235 inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) {
2236   typedef const size_t* _Ip;
2237   value_type* __t       = __begin_;
2238   const value_type* __s = __ia.__vp_;
2239   for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__t)
2240     *__t = __s[*__i];
2241   return *this;
2242 }
2243 
2244 template <class _Tp>
2245 template <class _ValExpr>
2246 inline valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) {
2247   size_t __n = __v.size();
2248   if (size() != __n)
2249     resize(__n);
2250   value_type* __t = __begin_;
2251   for (size_t __i = 0; __i != __n; ++__t, ++__i)
2252     *__t = __result_type(__v[__i]);
2253   return *this;
2254 }
2255 
2256 template <class _Tp>
2257 inline __val_expr<__slice_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](slice __s) const {
2258   return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
2259 }
2260 
2261 template <class _Tp>
2262 inline slice_array<_Tp> valarray<_Tp>::operator[](slice __s) {
2263   return slice_array<value_type>(__s, *this);
2264 }
2265 
2266 template <class _Tp>
2267 inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const gslice& __gs) const {
2268   return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
2269 }
2270 
2271 template <class _Tp>
2272 inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) {
2273   return gslice_array<value_type>(__gs, *this);
2274 }
2275 
2276 #ifndef _LIBCPP_CXX03_LANG
2277 
2278 template <class _Tp>
2279 inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](gslice&& __gs) const {
2280   return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this));
2281 }
2282 
2283 template <class _Tp>
2284 inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) {
2285   return gslice_array<value_type>(std::move(__gs), *this);
2286 }
2287 
2288 #endif // _LIBCPP_CXX03_LANG
2289 
2290 template <class _Tp>
2291 inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const {
2292   return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
2293 }
2294 
2295 template <class _Tp>
2296 inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) {
2297   return mask_array<value_type>(__vb, *this);
2298 }
2299 
2300 #ifndef _LIBCPP_CXX03_LANG
2301 
2302 template <class _Tp>
2303 inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<bool>&& __vb) const {
2304   return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this));
2305 }
2306 
2307 template <class _Tp>
2308 inline mask_array<_Tp> valarray<_Tp>::operator[](valarray<bool>&& __vb) {
2309   return mask_array<value_type>(std::move(__vb), *this);
2310 }
2311 
2312 #endif // _LIBCPP_CXX03_LANG
2313 
2314 template <class _Tp>
2315 inline __val_expr<__indirect_expr<const valarray<_Tp>&> >
2316 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const {
2317   return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
2318 }
2319 
2320 template <class _Tp>
2321 inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __vs) {
2322   return indirect_array<value_type>(__vs, *this);
2323 }
2324 
2325 #ifndef _LIBCPP_CXX03_LANG
2326 
2327 template <class _Tp>
2328 inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<size_t>&& __vs) const {
2329   return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this));
2330 }
2331 
2332 template <class _Tp>
2333 inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray<size_t>&& __vs) {
2334   return indirect_array<value_type>(std::move(__vs), *this);
2335 }
2336 
2337 #endif // _LIBCPP_CXX03_LANG
2338 
2339 template <class _Tp>
2340 inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const {
2341   using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>;
2342   return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this));
2343 }
2344 
2345 template <class _Tp>
2346 inline __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator-() const {
2347   using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>;
2348   return __val_expr<_Op>(_Op(negate<_Tp>(), *this));
2349 }
2350 
2351 template <class _Tp>
2352 inline __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator~() const {
2353   using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>;
2354   return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this));
2355 }
2356 
2357 template <class _Tp>
2358 inline __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator!() const {
2359   using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>;
2360   return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this));
2361 }
2362 
2363 template <class _Tp>
2364 inline valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) {
2365   for (value_type* __p = __begin_; __p != __end_; ++__p)
2366     *__p *= __x;
2367   return *this;
2368 }
2369 
2370 template <class _Tp>
2371 inline valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) {
2372   for (value_type* __p = __begin_; __p != __end_; ++__p)
2373     *__p /= __x;
2374   return *this;
2375 }
2376 
2377 template <class _Tp>
2378 inline valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) {
2379   for (value_type* __p = __begin_; __p != __end_; ++__p)
2380     *__p %= __x;
2381   return *this;
2382 }
2383 
2384 template <class _Tp>
2385 inline valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) {
2386   for (value_type* __p = __begin_; __p != __end_; ++__p)
2387     *__p += __x;
2388   return *this;
2389 }
2390 
2391 template <class _Tp>
2392 inline valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) {
2393   for (value_type* __p = __begin_; __p != __end_; ++__p)
2394     *__p -= __x;
2395   return *this;
2396 }
2397 
2398 template <class _Tp>
2399 inline valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) {
2400   for (value_type* __p = __begin_; __p != __end_; ++__p)
2401     *__p ^= __x;
2402   return *this;
2403 }
2404 
2405 template <class _Tp>
2406 inline valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) {
2407   for (value_type* __p = __begin_; __p != __end_; ++__p)
2408     *__p &= __x;
2409   return *this;
2410 }
2411 
2412 template <class _Tp>
2413 inline valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) {
2414   for (value_type* __p = __begin_; __p != __end_; ++__p)
2415     *__p |= __x;
2416   return *this;
2417 }
2418 
2419 template <class _Tp>
2420 inline valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) {
2421   for (value_type* __p = __begin_; __p != __end_; ++__p)
2422     *__p <<= __x;
2423   return *this;
2424 }
2425 
2426 template <class _Tp>
2427 inline valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) {
2428   for (value_type* __p = __begin_; __p != __end_; ++__p)
2429     *__p >>= __x;
2430   return *this;
2431 }
2432 
2433 template <class _Tp>
2434 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2435 inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) {
2436   size_t __i = 0;
2437   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2438     *__t *= std::__get(__v, __i);
2439   return *this;
2440 }
2441 
2442 template <class _Tp>
2443 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2444 inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) {
2445   size_t __i = 0;
2446   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2447     *__t /= std::__get(__v, __i);
2448   return *this;
2449 }
2450 
2451 template <class _Tp>
2452 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2453 inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) {
2454   size_t __i = 0;
2455   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2456     *__t %= std::__get(__v, __i);
2457   return *this;
2458 }
2459 
2460 template <class _Tp>
2461 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2462 inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) {
2463   size_t __i = 0;
2464   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2465     *__t += std::__get(__v, __i);
2466   return *this;
2467 }
2468 
2469 template <class _Tp>
2470 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2471 inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) {
2472   size_t __i = 0;
2473   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2474     *__t -= std::__get(__v, __i);
2475   return *this;
2476 }
2477 
2478 template <class _Tp>
2479 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2480 inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) {
2481   size_t __i = 0;
2482   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2483     *__t ^= std::__get(__v, __i);
2484   return *this;
2485 }
2486 
2487 template <class _Tp>
2488 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2489 inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) {
2490   size_t __i = 0;
2491   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2492     *__t |= std::__get(__v, __i);
2493   return *this;
2494 }
2495 
2496 template <class _Tp>
2497 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2498 inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) {
2499   size_t __i = 0;
2500   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2501     *__t &= std::__get(__v, __i);
2502   return *this;
2503 }
2504 
2505 template <class _Tp>
2506 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2507 inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) {
2508   size_t __i = 0;
2509   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2510     *__t <<= std::__get(__v, __i);
2511   return *this;
2512 }
2513 
2514 template <class _Tp>
2515 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
2516 inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) {
2517   size_t __i = 0;
2518   for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2519     *__t >>= std::__get(__v, __i);
2520   return *this;
2521 }
2522 
2523 template <class _Tp>
2524 inline void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT {
2525   std::swap(__begin_, __v.__begin_);
2526   std::swap(__end_, __v.__end_);
2527 }
2528 
2529 template <class _Tp>
2530 inline _Tp valarray<_Tp>::sum() const {
2531   if (__begin_ == __end_)
2532     return value_type();
2533   const value_type* __p = __begin_;
2534   _Tp __r               = *__p;
2535   for (++__p; __p != __end_; ++__p)
2536     __r += *__p;
2537   return __r;
2538 }
2539 
2540 template <class _Tp>
2541 inline _Tp valarray<_Tp>::min() const {
2542   if (__begin_ == __end_)
2543     return value_type();
2544   return *std::min_element(__begin_, __end_);
2545 }
2546 
2547 template <class _Tp>
2548 inline _Tp valarray<_Tp>::max() const {
2549   if (__begin_ == __end_)
2550     return value_type();
2551   return *std::max_element(__begin_, __end_);
2552 }
2553 
2554 template <class _Tp>
2555 valarray<_Tp> valarray<_Tp>::shift(int __i) const {
2556   valarray<value_type> __r;
2557   size_t __n = size();
2558   if (__n) {
2559     __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
2560     const value_type* __sb;
2561     value_type* __tb;
2562     value_type* __te;
2563     if (__i >= 0) {
2564       __i  = std::min(__i, static_cast<int>(__n));
2565       __sb = __begin_ + __i;
2566       __tb = __r.__begin_;
2567       __te = __r.__begin_ + (__n - __i);
2568     } else {
2569       __i  = std::min(-__i, static_cast<int>(__n));
2570       __sb = __begin_;
2571       __tb = __r.__begin_ + __i;
2572       __te = __r.__begin_ + __n;
2573     }
2574     for (; __r.__end_ != __tb; ++__r.__end_)
2575       ::new ((void*)__r.__end_) value_type();
2576     for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
2577       ::new ((void*)__r.__end_) value_type(*__sb);
2578     for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
2579       ::new ((void*)__r.__end_) value_type();
2580   }
2581   return __r;
2582 }
2583 
2584 template <class _Tp>
2585 valarray<_Tp> valarray<_Tp>::cshift(int __i) const {
2586   valarray<value_type> __r;
2587   size_t __n = size();
2588   if (__n) {
2589     __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
2590     __i %= static_cast<int>(__n);
2591     const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
2592     for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
2593       ::new ((void*)__r.__end_) value_type(*__s);
2594     for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
2595       ::new ((void*)__r.__end_) value_type(*__s);
2596   }
2597   return __r;
2598 }
2599 
2600 template <class _Tp>
2601 valarray<_Tp> valarray<_Tp>::apply(value_type __f(value_type)) const {
2602   valarray<value_type> __r;
2603   size_t __n = size();
2604   if (__n) {
2605     __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
2606     for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
2607       ::new ((void*)__r.__end_) value_type(__f(*__p));
2608   }
2609   return __r;
2610 }
2611 
2612 template <class _Tp>
2613 valarray<_Tp> valarray<_Tp>::apply(value_type __f(const value_type&)) const {
2614   valarray<value_type> __r;
2615   size_t __n = size();
2616   if (__n) {
2617     __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
2618     for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
2619       ::new ((void*)__r.__end_) value_type(__f(*__p));
2620   }
2621   return __r;
2622 }
2623 
2624 template <class _Tp>
2625 inline void valarray<_Tp>::__clear(size_t __capacity) {
2626   if (__begin_ != nullptr) {
2627     while (__end_ != __begin_)
2628       (--__end_)->~value_type();
2629     allocator<value_type>().deallocate(__begin_, __capacity);
2630     __begin_ = __end_ = nullptr;
2631   }
2632 }
2633 
2634 template <class _Tp>
2635 void valarray<_Tp>::resize(size_t __n, value_type __x) {
2636   __clear(size());
2637   if (__n) {
2638     __begin_ = __end_ = allocator<value_type>().allocate(__n);
2639 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2640     try {
2641 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2642       for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
2643         ::new ((void*)__end_) value_type(__x);
2644 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2645     } catch (...) {
2646       __clear(__n);
2647       throw;
2648     }
2649 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
2650   }
2651 }
2652 
2653 template <class _Tp>
2654 inline _LIBCPP_HIDE_FROM_ABI void swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT {
2655   __x.swap(__y);
2656 }
2657 
2658 template <class _Expr1,
2659           class _Expr2,
2660           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2661 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
2662 operator*(const _Expr1& __x, const _Expr2& __y) {
2663   typedef typename _Expr1::value_type value_type;
2664   typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
2665   return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
2666 }
2667 
2668 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2669 inline _LIBCPP_HIDE_FROM_ABI
2670 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2671 operator*(const _Expr& __x, const typename _Expr::value_type& __y) {
2672   typedef typename _Expr::value_type value_type;
2673   typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2674   return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2675 }
2676 
2677 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2678 inline _LIBCPP_HIDE_FROM_ABI
2679 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2680 operator*(const typename _Expr::value_type& __x, const _Expr& __y) {
2681   typedef typename _Expr::value_type value_type;
2682   typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2683   return __val_expr<_Op>(_Op(multiplies<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2684 }
2685 
2686 template <class _Expr1,
2687           class _Expr2,
2688           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2689 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
2690 operator/(const _Expr1& __x, const _Expr2& __y) {
2691   typedef typename _Expr1::value_type value_type;
2692   typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
2693   return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
2694 }
2695 
2696 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2697 inline _LIBCPP_HIDE_FROM_ABI
2698 __val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2699 operator/(const _Expr& __x, const typename _Expr::value_type& __y) {
2700   typedef typename _Expr::value_type value_type;
2701   typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2702   return __val_expr<_Op>(_Op(divides<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2703 }
2704 
2705 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2706 inline _LIBCPP_HIDE_FROM_ABI
2707 __val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2708 operator/(const typename _Expr::value_type& __x, const _Expr& __y) {
2709   typedef typename _Expr::value_type value_type;
2710   typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2711   return __val_expr<_Op>(_Op(divides<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2712 }
2713 
2714 template <class _Expr1,
2715           class _Expr2,
2716           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2717 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
2718 operator%(const _Expr1& __x, const _Expr2& __y) {
2719   typedef typename _Expr1::value_type value_type;
2720   typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
2721   return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
2722 }
2723 
2724 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2725 inline _LIBCPP_HIDE_FROM_ABI
2726 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2727 operator%(const _Expr& __x, const typename _Expr::value_type& __y) {
2728   typedef typename _Expr::value_type value_type;
2729   typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2730   return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2731 }
2732 
2733 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2734 inline _LIBCPP_HIDE_FROM_ABI
2735 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2736 operator%(const typename _Expr::value_type& __x, const _Expr& __y) {
2737   typedef typename _Expr::value_type value_type;
2738   typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2739   return __val_expr<_Op>(_Op(modulus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2740 }
2741 
2742 template <class _Expr1,
2743           class _Expr2,
2744           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2745 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
2746 operator+(const _Expr1& __x, const _Expr2& __y) {
2747   typedef typename _Expr1::value_type value_type;
2748   typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
2749   return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
2750 }
2751 
2752 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2753 inline _LIBCPP_HIDE_FROM_ABI
2754 __val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2755 operator+(const _Expr& __x, const typename _Expr::value_type& __y) {
2756   typedef typename _Expr::value_type value_type;
2757   typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2758   return __val_expr<_Op>(_Op(plus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2759 }
2760 
2761 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2762 inline _LIBCPP_HIDE_FROM_ABI
2763 __val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2764 operator+(const typename _Expr::value_type& __x, const _Expr& __y) {
2765   typedef typename _Expr::value_type value_type;
2766   typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2767   return __val_expr<_Op>(_Op(plus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2768 }
2769 
2770 template <class _Expr1,
2771           class _Expr2,
2772           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2773 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
2774 operator-(const _Expr1& __x, const _Expr2& __y) {
2775   typedef typename _Expr1::value_type value_type;
2776   typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
2777   return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
2778 }
2779 
2780 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2781 inline _LIBCPP_HIDE_FROM_ABI
2782 __val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2783 operator-(const _Expr& __x, const typename _Expr::value_type& __y) {
2784   typedef typename _Expr::value_type value_type;
2785   typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2786   return __val_expr<_Op>(_Op(minus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2787 }
2788 
2789 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2790 inline _LIBCPP_HIDE_FROM_ABI
2791 __val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2792 operator-(const typename _Expr::value_type& __x, const _Expr& __y) {
2793   typedef typename _Expr::value_type value_type;
2794   typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2795   return __val_expr<_Op>(_Op(minus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2796 }
2797 
2798 template <class _Expr1,
2799           class _Expr2,
2800           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2801 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
2802 operator^(const _Expr1& __x, const _Expr2& __y) {
2803   typedef typename _Expr1::value_type value_type;
2804   typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
2805   return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
2806 }
2807 
2808 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2809 inline _LIBCPP_HIDE_FROM_ABI
2810 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2811 operator^(const _Expr& __x, const typename _Expr::value_type& __y) {
2812   typedef typename _Expr::value_type value_type;
2813   typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2814   return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2815 }
2816 
2817 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2818 inline _LIBCPP_HIDE_FROM_ABI
2819 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2820 operator^(const typename _Expr::value_type& __x, const _Expr& __y) {
2821   typedef typename _Expr::value_type value_type;
2822   typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2823   return __val_expr<_Op>(_Op(bit_xor<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2824 }
2825 
2826 template <class _Expr1,
2827           class _Expr2,
2828           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2829 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
2830 operator&(const _Expr1& __x, const _Expr2& __y) {
2831   typedef typename _Expr1::value_type value_type;
2832   typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
2833   return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
2834 }
2835 
2836 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2837 inline _LIBCPP_HIDE_FROM_ABI
2838 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2839 operator&(const _Expr& __x, const typename _Expr::value_type& __y) {
2840   typedef typename _Expr::value_type value_type;
2841   typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2842   return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2843 }
2844 
2845 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2846 inline _LIBCPP_HIDE_FROM_ABI
2847 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2848 operator&(const typename _Expr::value_type& __x, const _Expr& __y) {
2849   typedef typename _Expr::value_type value_type;
2850   typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2851   return __val_expr<_Op>(_Op(bit_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2852 }
2853 
2854 template <class _Expr1,
2855           class _Expr2,
2856           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2857 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
2858 operator|(const _Expr1& __x, const _Expr2& __y) {
2859   typedef typename _Expr1::value_type value_type;
2860   typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
2861   return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
2862 }
2863 
2864 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2865 inline _LIBCPP_HIDE_FROM_ABI
2866 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2867 operator|(const _Expr& __x, const typename _Expr::value_type& __y) {
2868   typedef typename _Expr::value_type value_type;
2869   typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2870   return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2871 }
2872 
2873 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2874 inline _LIBCPP_HIDE_FROM_ABI
2875 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2876 operator|(const typename _Expr::value_type& __x, const _Expr& __y) {
2877   typedef typename _Expr::value_type value_type;
2878   typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2879   return __val_expr<_Op>(_Op(bit_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2880 }
2881 
2882 template <class _Expr1,
2883           class _Expr2,
2884           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2885 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
2886 operator<<(const _Expr1& __x, const _Expr2& __y) {
2887   typedef typename _Expr1::value_type value_type;
2888   typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
2889   return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
2890 }
2891 
2892 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2893 inline _LIBCPP_HIDE_FROM_ABI
2894 __val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2895 operator<<(const _Expr& __x, const typename _Expr::value_type& __y) {
2896   typedef typename _Expr::value_type value_type;
2897   typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2898   return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2899 }
2900 
2901 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2902 inline _LIBCPP_HIDE_FROM_ABI
2903 __val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2904 operator<<(const typename _Expr::value_type& __x, const _Expr& __y) {
2905   typedef typename _Expr::value_type value_type;
2906   typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2907   return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2908 }
2909 
2910 template <class _Expr1,
2911           class _Expr2,
2912           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2913 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
2914 operator>>(const _Expr1& __x, const _Expr2& __y) {
2915   typedef typename _Expr1::value_type value_type;
2916   typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
2917   return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
2918 }
2919 
2920 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2921 inline _LIBCPP_HIDE_FROM_ABI __val_expr<
2922     _BinaryOp<__bit_shift_right<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2923 operator>>(const _Expr& __x, const typename _Expr::value_type& __y) {
2924   typedef typename _Expr::value_type value_type;
2925   typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2926   return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2927 }
2928 
2929 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2930 inline _LIBCPP_HIDE_FROM_ABI
2931 __val_expr< _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2932 operator>>(const typename _Expr::value_type& __x, const _Expr& __y) {
2933   typedef typename _Expr::value_type value_type;
2934   typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2935   return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2936 }
2937 
2938 template <class _Expr1,
2939           class _Expr2,
2940           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2941 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
2942 operator&&(const _Expr1& __x, const _Expr2& __y) {
2943   typedef typename _Expr1::value_type value_type;
2944   typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
2945   return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
2946 }
2947 
2948 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2949 inline _LIBCPP_HIDE_FROM_ABI
2950 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2951 operator&&(const _Expr& __x, const typename _Expr::value_type& __y) {
2952   typedef typename _Expr::value_type value_type;
2953   typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2954   return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2955 }
2956 
2957 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2958 inline _LIBCPP_HIDE_FROM_ABI
2959 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2960 operator&&(const typename _Expr::value_type& __x, const _Expr& __y) {
2961   typedef typename _Expr::value_type value_type;
2962   typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2963   return __val_expr<_Op>(_Op(logical_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2964 }
2965 
2966 template <class _Expr1,
2967           class _Expr2,
2968           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2969 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
2970 operator||(const _Expr1& __x, const _Expr2& __y) {
2971   typedef typename _Expr1::value_type value_type;
2972   typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
2973   return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
2974 }
2975 
2976 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2977 inline _LIBCPP_HIDE_FROM_ABI
2978 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2979 operator||(const _Expr& __x, const typename _Expr::value_type& __y) {
2980   typedef typename _Expr::value_type value_type;
2981   typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
2982   return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
2983 }
2984 
2985 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2986 inline _LIBCPP_HIDE_FROM_ABI
2987 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2988 operator||(const typename _Expr::value_type& __x, const _Expr& __y) {
2989   typedef typename _Expr::value_type value_type;
2990   typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
2991   return __val_expr<_Op>(_Op(logical_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
2992 }
2993 
2994 template <class _Expr1,
2995           class _Expr2,
2996           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
2997 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
2998 operator==(const _Expr1& __x, const _Expr2& __y) {
2999   typedef typename _Expr1::value_type value_type;
3000   typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
3001   return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
3002 }
3003 
3004 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3005 inline _LIBCPP_HIDE_FROM_ABI
3006 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3007 operator==(const _Expr& __x, const typename _Expr::value_type& __y) {
3008   typedef typename _Expr::value_type value_type;
3009   typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3010   return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3011 }
3012 
3013 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3014 inline _LIBCPP_HIDE_FROM_ABI
3015 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3016 operator==(const typename _Expr::value_type& __x, const _Expr& __y) {
3017   typedef typename _Expr::value_type value_type;
3018   typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3019   return __val_expr<_Op>(_Op(equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3020 }
3021 
3022 template <class _Expr1,
3023           class _Expr2,
3024           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3025 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
3026 operator!=(const _Expr1& __x, const _Expr2& __y) {
3027   typedef typename _Expr1::value_type value_type;
3028   typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
3029   return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
3030 }
3031 
3032 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3033 inline _LIBCPP_HIDE_FROM_ABI
3034 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3035 operator!=(const _Expr& __x, const typename _Expr::value_type& __y) {
3036   typedef typename _Expr::value_type value_type;
3037   typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3038   return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3039 }
3040 
3041 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3042 inline _LIBCPP_HIDE_FROM_ABI
3043 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3044 operator!=(const typename _Expr::value_type& __x, const _Expr& __y) {
3045   typedef typename _Expr::value_type value_type;
3046   typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3047   return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3048 }
3049 
3050 template <class _Expr1,
3051           class _Expr2,
3052           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3053 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
3054 operator<(const _Expr1& __x, const _Expr2& __y) {
3055   typedef typename _Expr1::value_type value_type;
3056   typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
3057   return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
3058 }
3059 
3060 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3061 inline _LIBCPP_HIDE_FROM_ABI
3062 __val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3063 operator<(const _Expr& __x, const typename _Expr::value_type& __y) {
3064   typedef typename _Expr::value_type value_type;
3065   typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3066   return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3067 }
3068 
3069 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3070 inline _LIBCPP_HIDE_FROM_ABI
3071 __val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3072 operator<(const typename _Expr::value_type& __x, const _Expr& __y) {
3073   typedef typename _Expr::value_type value_type;
3074   typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3075   return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3076 }
3077 
3078 template <class _Expr1,
3079           class _Expr2,
3080           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3081 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
3082 operator>(const _Expr1& __x, const _Expr2& __y) {
3083   typedef typename _Expr1::value_type value_type;
3084   typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
3085   return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
3086 }
3087 
3088 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3089 inline _LIBCPP_HIDE_FROM_ABI
3090 __val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3091 operator>(const _Expr& __x, const typename _Expr::value_type& __y) {
3092   typedef typename _Expr::value_type value_type;
3093   typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3094   return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3095 }
3096 
3097 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3098 inline _LIBCPP_HIDE_FROM_ABI
3099 __val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3100 operator>(const typename _Expr::value_type& __x, const _Expr& __y) {
3101   typedef typename _Expr::value_type value_type;
3102   typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3103   return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3104 }
3105 
3106 template <class _Expr1,
3107           class _Expr2,
3108           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3109 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
3110 operator<=(const _Expr1& __x, const _Expr2& __y) {
3111   typedef typename _Expr1::value_type value_type;
3112   typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
3113   return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
3114 }
3115 
3116 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3117 inline _LIBCPP_HIDE_FROM_ABI
3118 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3119 operator<=(const _Expr& __x, const typename _Expr::value_type& __y) {
3120   typedef typename _Expr::value_type value_type;
3121   typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3122   return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3123 }
3124 
3125 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3126 inline _LIBCPP_HIDE_FROM_ABI
3127 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3128 operator<=(const typename _Expr::value_type& __x, const _Expr& __y) {
3129   typedef typename _Expr::value_type value_type;
3130   typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3131   return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3132 }
3133 
3134 template <class _Expr1,
3135           class _Expr2,
3136           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3137 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
3138 operator>=(const _Expr1& __x, const _Expr2& __y) {
3139   typedef typename _Expr1::value_type value_type;
3140   typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
3141   return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
3142 }
3143 
3144 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3145 inline _LIBCPP_HIDE_FROM_ABI
3146 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3147 operator>=(const _Expr& __x, const typename _Expr::value_type& __y) {
3148   typedef typename _Expr::value_type value_type;
3149   typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3150   return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3151 }
3152 
3153 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3154 inline _LIBCPP_HIDE_FROM_ABI
3155 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3156 operator>=(const typename _Expr::value_type& __x, const _Expr& __y) {
3157   typedef typename _Expr::value_type value_type;
3158   typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3159   return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3160 }
3161 
3162 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3163 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
3164 abs(const _Expr& __x) {
3165   typedef typename _Expr::value_type value_type;
3166   typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
3167   return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
3168 }
3169 
3170 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3171 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
3172 acos(const _Expr& __x) {
3173   typedef typename _Expr::value_type value_type;
3174   typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
3175   return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
3176 }
3177 
3178 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3179 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
3180 asin(const _Expr& __x) {
3181   typedef typename _Expr::value_type value_type;
3182   typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
3183   return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
3184 }
3185 
3186 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3187 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
3188 atan(const _Expr& __x) {
3189   typedef typename _Expr::value_type value_type;
3190   typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
3191   return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
3192 }
3193 
3194 template <class _Expr1,
3195           class _Expr2,
3196           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3197 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
3198 atan2(const _Expr1& __x, const _Expr2& __y) {
3199   typedef typename _Expr1::value_type value_type;
3200   typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
3201   return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
3202 }
3203 
3204 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3205 inline _LIBCPP_HIDE_FROM_ABI
3206 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3207 atan2(const _Expr& __x, const typename _Expr::value_type& __y) {
3208   typedef typename _Expr::value_type value_type;
3209   typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3210   return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3211 }
3212 
3213 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3214 inline _LIBCPP_HIDE_FROM_ABI
3215 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3216 atan2(const typename _Expr::value_type& __x, const _Expr& __y) {
3217   typedef typename _Expr::value_type value_type;
3218   typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3219   return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3220 }
3221 
3222 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3223 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
3224 cos(const _Expr& __x) {
3225   typedef typename _Expr::value_type value_type;
3226   typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
3227   return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
3228 }
3229 
3230 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3231 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
3232 cosh(const _Expr& __x) {
3233   typedef typename _Expr::value_type value_type;
3234   typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
3235   return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
3236 }
3237 
3238 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3239 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
3240 exp(const _Expr& __x) {
3241   typedef typename _Expr::value_type value_type;
3242   typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
3243   return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
3244 }
3245 
3246 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3247 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
3248 log(const _Expr& __x) {
3249   typedef typename _Expr::value_type value_type;
3250   typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
3251   return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
3252 }
3253 
3254 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3255 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
3256 log10(const _Expr& __x) {
3257   typedef typename _Expr::value_type value_type;
3258   typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
3259   return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
3260 }
3261 
3262 template <class _Expr1,
3263           class _Expr2,
3264           __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>
3265 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
3266 pow(const _Expr1& __x, const _Expr2& __y) {
3267   typedef typename _Expr1::value_type value_type;
3268   typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
3269   return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
3270 }
3271 
3272 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3273 inline _LIBCPP_HIDE_FROM_ABI
3274 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3275 pow(const _Expr& __x, const typename _Expr::value_type& __y) {
3276   typedef typename _Expr::value_type value_type;
3277   typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3278   return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
3279 }
3280 
3281 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3282 inline _LIBCPP_HIDE_FROM_ABI
3283 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3284 pow(const typename _Expr::value_type& __x, const _Expr& __y) {
3285   typedef typename _Expr::value_type value_type;
3286   typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3287   return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
3288 }
3289 
3290 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3291 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
3292 sin(const _Expr& __x) {
3293   typedef typename _Expr::value_type value_type;
3294   typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
3295   return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
3296 }
3297 
3298 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3299 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
3300 sinh(const _Expr& __x) {
3301   typedef typename _Expr::value_type value_type;
3302   typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
3303   return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
3304 }
3305 
3306 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3307 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
3308 sqrt(const _Expr& __x) {
3309   typedef typename _Expr::value_type value_type;
3310   typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
3311   return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
3312 }
3313 
3314 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3315 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
3316 tan(const _Expr& __x) {
3317   typedef typename _Expr::value_type value_type;
3318   typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
3319   return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
3320 }
3321 
3322 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
3323 inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
3324 tanh(const _Expr& __x) {
3325   typedef typename _Expr::value_type value_type;
3326   typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
3327   return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
3328 }
3329 
3330 template <class _Tp>
3331 inline _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v) {
3332   return __v.__begin_;
3333 }
3334 
3335 template <class _Tp>
3336 inline _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v) {
3337   return __v.__begin_;
3338 }
3339 
3340 template <class _Tp>
3341 inline _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v) {
3342   return __v.__end_;
3343 }
3344 
3345 template <class _Tp>
3346 inline _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v) {
3347   return __v.__end_;
3348 }
3349 
3350 _LIBCPP_END_NAMESPACE_STD
3351 
3352 _LIBCPP_POP_MACROS
3353 
3354 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
3355 #  include <__cxx03/algorithm>
3356 #  include <__cxx03/concepts>
3357 #  include <__cxx03/cstdlib>
3358 #  include <__cxx03/cstring>
3359 #  include <__cxx03/functional>
3360 #  include <__cxx03/stdexcept>
3361 #  include <__cxx03/type_traits>
3362 #endif
3363 
3364 #endif // _LIBCPP___CXX03_VALARRAY