Back to home page

EIC code displayed by LXR

 
 

    


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