Home | History | Annotate | Download | only in include
      1 // -*- C++ -*-
      2 //===-------------------------- valarray ----------------------------------===//
      3 //
      4 //                     The LLVM Compiler Infrastructure
      5 //
      6 // This file is dual licensed under the MIT and the University of Illinois Open
      7 // Source Licenses. See LICENSE.TXT for details.
      8 //
      9 //===----------------------------------------------------------------------===//
     10 
     11 #ifndef _LIBCPP_VALARRAY
     12 #define _LIBCPP_VALARRAY
     13 
     14 /*
     15     valarray synopsis
     16 
     17 namespace std
     18 {
     19 
     20 template<class T>
     21 class valarray
     22 {
     23 public:
     24     typedef T value_type;
     25 
     26     // construct/destroy:
     27     valarray();
     28     explicit valarray(size_t n);
     29     valarray(const value_type& x, size_t n);
     30     valarray(const value_type* px, size_t n);
     31     valarray(const valarray& v);
     32     valarray(valarray&& v) noexcept;
     33     valarray(const slice_array<value_type>& sa);
     34     valarray(const gslice_array<value_type>& ga);
     35     valarray(const mask_array<value_type>& ma);
     36     valarray(const indirect_array<value_type>& ia);
     37     valarray(initializer_list<value_type> il);
     38     ~valarray();
     39 
     40     // assignment:
     41     valarray& operator=(const valarray& v);
     42     valarray& operator=(valarray&& v) noexcept;
     43     valarray& operator=(initializer_list<value_type> il);
     44     valarray& operator=(const value_type& x);
     45     valarray& operator=(const slice_array<value_type>& sa);
     46     valarray& operator=(const gslice_array<value_type>& ga);
     47     valarray& operator=(const mask_array<value_type>& ma);
     48     valarray& operator=(const indirect_array<value_type>& ia);
     49 
     50     // element access:
     51     const value_type& operator[](size_t i) const;
     52     value_type&       operator[](size_t i);
     53 
     54     // subset operations:
     55     valarray                   operator[](slice s) const;
     56     slice_array<value_type>    operator[](slice s);
     57     valarray                   operator[](const gslice& gs) const;
     58     gslice_array<value_type>   operator[](const gslice& gs);
     59     valarray                   operator[](const valarray<bool>& vb) const;
     60     mask_array<value_type>     operator[](const valarray<bool>& vb);
     61     valarray                   operator[](const valarray<size_t>& vs) const;
     62     indirect_array<value_type> operator[](const valarray<size_t>& vs);
     63 
     64     // unary operators:
     65     valarray       operator+() const;
     66     valarray       operator-() const;
     67     valarray       operator~() const;
     68     valarray<bool> operator!() const;
     69 
     70     // computed assignment:
     71     valarray& operator*= (const value_type& x);
     72     valarray& operator/= (const value_type& x);
     73     valarray& operator%= (const value_type& x);
     74     valarray& operator+= (const value_type& x);
     75     valarray& operator-= (const value_type& x);
     76     valarray& operator^= (const value_type& x);
     77     valarray& operator&= (const value_type& x);
     78     valarray& operator|= (const value_type& x);
     79     valarray& operator<<=(const value_type& x);
     80     valarray& operator>>=(const value_type& x);
     81 
     82     valarray& operator*= (const valarray& v);
     83     valarray& operator/= (const valarray& v);
     84     valarray& operator%= (const valarray& v);
     85     valarray& operator+= (const valarray& v);
     86     valarray& operator-= (const valarray& v);
     87     valarray& operator^= (const valarray& v);
     88     valarray& operator|= (const valarray& v);
     89     valarray& operator&= (const valarray& v);
     90     valarray& operator<<=(const valarray& v);
     91     valarray& operator>>=(const valarray& v);
     92 
     93     // member functions:
     94     void swap(valarray& v) noexcept;
     95 
     96     size_t size() const;
     97 
     98     value_type sum() const;
     99     value_type min() const;
    100     value_type max() const;
    101 
    102     valarray shift (int i) const;
    103     valarray cshift(int i) const;
    104     valarray apply(value_type f(value_type)) const;
    105     valarray apply(value_type f(const value_type&)) const;
    106     void resize(size_t n, value_type x = value_type());
    107 };
    108 
    109 class slice
    110 {
    111 public:
    112     slice();
    113     slice(size_t start, size_t size, size_t stride);
    114 
    115     size_t start()  const;
    116     size_t size()   const;
    117     size_t stride() const;
    118 };
    119 
    120 template <class T>
    121 class slice_array
    122 {
    123 public:
    124     typedef T value_type;
    125 
    126     const slice_array& operator=(const slice_array& sa) const;
    127     void operator=  (const valarray<value_type>& v) const;
    128     void operator*= (const valarray<value_type>& v) const;
    129     void operator/= (const valarray<value_type>& v) const;
    130     void operator%= (const valarray<value_type>& v) const;
    131     void operator+= (const valarray<value_type>& v) const;
    132     void operator-= (const valarray<value_type>& v) const;
    133     void operator^= (const valarray<value_type>& v) const;
    134     void operator&= (const valarray<value_type>& v) const;
    135     void operator|= (const valarray<value_type>& v) const;
    136     void operator<<=(const valarray<value_type>& v) const;
    137     void operator>>=(const valarray<value_type>& v) const;
    138 
    139     void operator=(const value_type& x) const;
    140 
    141     slice_array() = delete;
    142 };
    143 
    144 class gslice
    145 {
    146 public:
    147     gslice();
    148     gslice(size_t start, const valarray<size_t>& size,
    149                          const valarray<size_t>& stride);
    150 
    151     size_t           start()  const;
    152     valarray<size_t> size()   const;
    153     valarray<size_t> stride() const;
    154 };
    155 
    156 template <class T>
    157 class gslice_array
    158 {
    159 public:
    160     typedef T value_type;
    161 
    162     void operator=  (const valarray<value_type>& v) const;
    163     void operator*= (const valarray<value_type>& v) const;
    164     void operator/= (const valarray<value_type>& v) const;
    165     void operator%= (const valarray<value_type>& v) const;
    166     void operator+= (const valarray<value_type>& v) const;
    167     void operator-= (const valarray<value_type>& v) const;
    168     void operator^= (const valarray<value_type>& v) const;
    169     void operator&= (const valarray<value_type>& v) const;
    170     void operator|= (const valarray<value_type>& v) const;
    171     void operator<<=(const valarray<value_type>& v) const;
    172     void operator>>=(const valarray<value_type>& v) const;
    173 
    174     gslice_array(const gslice_array& ga);
    175     ~gslice_array();
    176     const gslice_array& operator=(const gslice_array& ga) const;
    177     void operator=(const value_type& x) const;
    178 
    179     gslice_array() = delete;
    180 };
    181 
    182 template <class T>
    183 class mask_array
    184 {
    185 public:
    186     typedef T value_type;
    187 
    188     void operator=  (const valarray<value_type>& v) const;
    189     void operator*= (const valarray<value_type>& v) const;
    190     void operator/= (const valarray<value_type>& v) const;
    191     void operator%= (const valarray<value_type>& v) const;
    192     void operator+= (const valarray<value_type>& v) const;
    193     void operator-= (const valarray<value_type>& v) const;
    194     void operator^= (const valarray<value_type>& v) const;
    195     void operator&= (const valarray<value_type>& v) const;
    196     void operator|= (const valarray<value_type>& v) const;
    197     void operator<<=(const valarray<value_type>& v) const;
    198     void operator>>=(const valarray<value_type>& v) const;
    199 
    200     mask_array(const mask_array& ma);
    201     ~mask_array();
    202     const mask_array& operator=(const mask_array& ma) const;
    203     void operator=(const value_type& x) const;
    204 
    205     mask_array() = delete;
    206 };
    207 
    208 template <class T>
    209 class indirect_array
    210 {
    211 public:
    212     typedef T value_type;
    213 
    214     void operator=  (const valarray<value_type>& v) const;
    215     void operator*= (const valarray<value_type>& v) const;
    216     void operator/= (const valarray<value_type>& v) const;
    217     void operator%= (const valarray<value_type>& v) const;
    218     void operator+= (const valarray<value_type>& v) const;
    219     void operator-= (const valarray<value_type>& v) const;
    220     void operator^= (const valarray<value_type>& v) const;
    221     void operator&= (const valarray<value_type>& v) const;
    222     void operator|= (const valarray<value_type>& v) const;
    223     void operator<<=(const valarray<value_type>& v) const;
    224     void operator>>=(const valarray<value_type>& v) const;
    225 
    226     indirect_array(const indirect_array& ia);
    227     ~indirect_array();
    228     const indirect_array& operator=(const indirect_array& ia) const;
    229     void operator=(const value_type& x) const;
    230 
    231     indirect_array() = delete;
    232 };
    233 
    234 template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
    235 
    236 template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
    237 template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
    238 template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
    239 
    240 template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
    241 template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
    242 template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
    243 
    244 template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
    245 template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
    246 template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
    247 
    248 template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
    249 template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
    250 template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
    251 
    252 template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
    253 template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
    254 template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
    255 
    256 template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
    257 template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
    258 template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
    259 
    260 template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
    261 template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
    262 template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
    263 
    264 template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
    265 template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
    266 template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
    267 
    268 template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
    269 template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
    270 template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
    271 
    272 template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
    273 template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
    274 template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
    275 
    276 template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
    277 template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
    278 template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
    279 
    280 template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
    281 template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
    282 template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
    283 
    284 template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
    285 template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
    286 template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
    287 
    288 template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
    289 template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
    290 template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
    291 
    292 template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
    293 template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
    294 template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
    295 
    296 template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
    297 template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
    298 template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
    299 
    300 template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
    301 template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
    302 template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
    303 
    304 template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
    305 template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
    306 template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
    307 
    308 template<class T> valarray<T> abs (const valarray<T>& x);
    309 template<class T> valarray<T> acos (const valarray<T>& x);
    310 template<class T> valarray<T> asin (const valarray<T>& x);
    311 template<class T> valarray<T> atan (const valarray<T>& x);
    312 
    313 template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
    314 template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
    315 template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
    316 
    317 template<class T> valarray<T> cos (const valarray<T>& x);
    318 template<class T> valarray<T> cosh (const valarray<T>& x);
    319 template<class T> valarray<T> exp (const valarray<T>& x);
    320 template<class T> valarray<T> log (const valarray<T>& x);
    321 template<class T> valarray<T> log10(const valarray<T>& x);
    322 
    323 template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
    324 template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
    325 template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
    326 
    327 template<class T> valarray<T> sin (const valarray<T>& x);
    328 template<class T> valarray<T> sinh (const valarray<T>& x);
    329 template<class T> valarray<T> sqrt (const valarray<T>& x);
    330 template<class T> valarray<T> tan (const valarray<T>& x);
    331 template<class T> valarray<T> tanh (const valarray<T>& x);
    332 
    333 template <class T> unspecified1 begin(valarray<T>& v);
    334 template <class T> unspecified2 begin(const valarray<T>& v);
    335 template <class T> unspecified1 end(valarray<T>& v);
    336 template <class T> unspecified2 end(const valarray<T>& v);
    337 
    338 }  // std
    339 
    340 */
    341 
    342 #include <__config>
    343 #include <cstddef>
    344 #include <cmath>
    345 #include <initializer_list>
    346 #include <algorithm>
    347 #include <functional>
    348 #include <new>
    349 
    350 #include <__undef_min_max>
    351 #include <__undef___deallocate>
    352 
    353 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
    354 #pragma GCC system_header
    355 #endif
    356 
    357 _LIBCPP_BEGIN_NAMESPACE_STD
    358 
    359 template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY valarray;
    360 
    361 class _LIBCPP_TYPE_VIS_ONLY slice
    362 {
    363     size_t __start_;
    364     size_t __size_;
    365     size_t __stride_;
    366 public:
    367     _LIBCPP_INLINE_VISIBILITY
    368     slice()
    369         : __start_(0),
    370           __size_(0),
    371           __stride_(0)
    372           {}
    373 
    374     _LIBCPP_INLINE_VISIBILITY
    375     slice(size_t __start, size_t __size, size_t __stride)
    376         : __start_(__start),
    377           __size_(__size),
    378           __stride_(__stride)
    379           {}
    380 
    381     _LIBCPP_INLINE_VISIBILITY size_t start()  const {return __start_;}
    382     _LIBCPP_INLINE_VISIBILITY size_t size()   const {return __size_;}
    383     _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
    384 };
    385 
    386 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY slice_array;
    387 class _LIBCPP_TYPE_VIS gslice;
    388 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY gslice_array;
    389 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY mask_array;
    390 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY indirect_array;
    391 
    392 template <class _Tp>
    393 _LIBCPP_INLINE_VISIBILITY
    394 _Tp*
    395 begin(valarray<_Tp>& __v);
    396 
    397 template <class _Tp>
    398 _LIBCPP_INLINE_VISIBILITY
    399 const _Tp*
    400 begin(const valarray<_Tp>& __v);
    401 
    402 template <class _Tp>
    403 _LIBCPP_INLINE_VISIBILITY
    404 _Tp*
    405 end(valarray<_Tp>& __v);
    406 
    407 template <class _Tp>
    408 _LIBCPP_INLINE_VISIBILITY
    409 const _Tp*
    410 end(const valarray<_Tp>& __v);
    411 
    412 template <class _Op, class _A0>
    413 struct _UnaryOp
    414 {
    415     typedef typename _Op::result_type result_type;
    416     typedef typename _A0::value_type value_type;
    417 
    418     _Op __op_;
    419     _A0 __a0_;
    420 
    421     _LIBCPP_INLINE_VISIBILITY
    422     _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
    423 
    424     _LIBCPP_INLINE_VISIBILITY
    425     result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
    426 
    427     _LIBCPP_INLINE_VISIBILITY
    428     size_t size() const {return __a0_.size();}
    429 };
    430 
    431 template <class _Op, class _A0, class _A1>
    432 struct _BinaryOp
    433 {
    434     typedef typename _Op::result_type result_type;
    435     typedef typename _A0::value_type value_type;
    436 
    437     _Op __op_;
    438     _A0 __a0_;
    439     _A1 __a1_;
    440 
    441     _LIBCPP_INLINE_VISIBILITY
    442     _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
    443         : __op_(__op), __a0_(__a0), __a1_(__a1) {}
    444 
    445     _LIBCPP_INLINE_VISIBILITY
    446     value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
    447 
    448     _LIBCPP_INLINE_VISIBILITY
    449     size_t size() const {return __a0_.size();}
    450 };
    451 
    452 template <class _Tp>
    453 class __scalar_expr
    454 {
    455 public:
    456     typedef _Tp        value_type;
    457     typedef const _Tp& result_type;
    458 private:
    459     const value_type& __t_;
    460     size_t __s_;
    461 public:
    462     _LIBCPP_INLINE_VISIBILITY
    463     explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
    464 
    465     _LIBCPP_INLINE_VISIBILITY
    466     result_type operator[](size_t) const {return __t_;}
    467 
    468     _LIBCPP_INLINE_VISIBILITY
    469     size_t size() const {return __s_;}
    470 };
    471 
    472 template <class _Tp>
    473 struct __unary_plus : unary_function<_Tp, _Tp>
    474 {
    475     _LIBCPP_INLINE_VISIBILITY
    476     _Tp operator()(const _Tp& __x) const
    477         {return +__x;}
    478 };
    479 
    480 template <class _Tp>
    481 struct __bit_not  : unary_function<_Tp, _Tp>
    482 {
    483     _LIBCPP_INLINE_VISIBILITY
    484     _Tp operator()(const _Tp& __x) const
    485         {return ~__x;}
    486 };
    487 
    488 template <class _Tp>
    489 struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
    490 {
    491     _LIBCPP_INLINE_VISIBILITY
    492     _Tp operator()(const _Tp& __x, const _Tp& __y) const
    493         {return __x << __y;}
    494 };
    495 
    496 template <class _Tp>
    497 struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
    498 {
    499     _LIBCPP_INLINE_VISIBILITY
    500     _Tp operator()(const _Tp& __x, const _Tp& __y) const
    501         {return __x >> __y;}
    502 };
    503 
    504 template <class _Tp, class _Fp>
    505 struct __apply_expr   : unary_function<_Tp, _Tp>
    506 {
    507 private:
    508     _Fp __f_;
    509 public:
    510     _LIBCPP_INLINE_VISIBILITY
    511     explicit __apply_expr(_Fp __f) : __f_(__f) {}
    512 
    513     _LIBCPP_INLINE_VISIBILITY
    514     _Tp operator()(const _Tp& __x) const
    515         {return __f_(__x);}
    516 };
    517 
    518 template <class _Tp>
    519 struct __abs_expr : unary_function<_Tp, _Tp>
    520 {
    521     _LIBCPP_INLINE_VISIBILITY
    522     _Tp operator()(const _Tp& __x) const
    523         {return abs(__x);}
    524 };
    525 
    526 template <class _Tp>
    527 struct __acos_expr : unary_function<_Tp, _Tp>
    528 {
    529     _LIBCPP_INLINE_VISIBILITY
    530     _Tp operator()(const _Tp& __x) const
    531         {return acos(__x);}
    532 };
    533 
    534 template <class _Tp>
    535 struct __asin_expr : unary_function<_Tp, _Tp>
    536 {
    537     _LIBCPP_INLINE_VISIBILITY
    538     _Tp operator()(const _Tp& __x) const
    539         {return asin(__x);}
    540 };
    541 
    542 template <class _Tp>
    543 struct __atan_expr : unary_function<_Tp, _Tp>
    544 {
    545     _LIBCPP_INLINE_VISIBILITY
    546     _Tp operator()(const _Tp& __x) const
    547         {return atan(__x);}
    548 };
    549 
    550 template <class _Tp>
    551 struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
    552 {
    553     _LIBCPP_INLINE_VISIBILITY
    554     _Tp operator()(const _Tp& __x, const _Tp& __y) const
    555         {return atan2(__x, __y);}
    556 };
    557 
    558 template <class _Tp>
    559 struct __cos_expr : unary_function<_Tp, _Tp>
    560 {
    561     _LIBCPP_INLINE_VISIBILITY
    562     _Tp operator()(const _Tp& __x) const
    563         {return cos(__x);}
    564 };
    565 
    566 template <class _Tp>
    567 struct __cosh_expr : unary_function<_Tp, _Tp>
    568 {
    569     _LIBCPP_INLINE_VISIBILITY
    570     _Tp operator()(const _Tp& __x) const
    571         {return cosh(__x);}
    572 };
    573 
    574 template <class _Tp>
    575 struct __exp_expr : unary_function<_Tp, _Tp>
    576 {
    577     _LIBCPP_INLINE_VISIBILITY
    578     _Tp operator()(const _Tp& __x) const
    579         {return exp(__x);}
    580 };
    581 
    582 template <class _Tp>
    583 struct __log_expr : unary_function<_Tp, _Tp>
    584 {
    585     _LIBCPP_INLINE_VISIBILITY
    586     _Tp operator()(const _Tp& __x) const
    587         {return log(__x);}
    588 };
    589 
    590 template <class _Tp>
    591 struct __log10_expr : unary_function<_Tp, _Tp>
    592 {
    593     _LIBCPP_INLINE_VISIBILITY
    594     _Tp operator()(const _Tp& __x) const
    595         {return log10(__x);}
    596 };
    597 
    598 template <class _Tp>
    599 struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
    600 {
    601     _LIBCPP_INLINE_VISIBILITY
    602     _Tp operator()(const _Tp& __x, const _Tp& __y) const
    603         {return pow(__x, __y);}
    604 };
    605 
    606 template <class _Tp>
    607 struct __sin_expr : unary_function<_Tp, _Tp>
    608 {
    609     _LIBCPP_INLINE_VISIBILITY
    610     _Tp operator()(const _Tp& __x) const
    611         {return sin(__x);}
    612 };
    613 
    614 template <class _Tp>
    615 struct __sinh_expr : unary_function<_Tp, _Tp>
    616 {
    617     _LIBCPP_INLINE_VISIBILITY
    618     _Tp operator()(const _Tp& __x) const
    619         {return sinh(__x);}
    620 };
    621 
    622 template <class _Tp>
    623 struct __sqrt_expr : unary_function<_Tp, _Tp>
    624 {
    625     _LIBCPP_INLINE_VISIBILITY
    626     _Tp operator()(const _Tp& __x) const
    627         {return sqrt(__x);}
    628 };
    629 
    630 template <class _Tp>
    631 struct __tan_expr : unary_function<_Tp, _Tp>
    632 {
    633     _LIBCPP_INLINE_VISIBILITY
    634     _Tp operator()(const _Tp& __x) const
    635         {return tan(__x);}
    636 };
    637 
    638 template <class _Tp>
    639 struct __tanh_expr : unary_function<_Tp, _Tp>
    640 {
    641     _LIBCPP_INLINE_VISIBILITY
    642     _Tp operator()(const _Tp& __x) const
    643         {return tanh(__x);}
    644 };
    645 
    646 template <class _ValExpr>
    647 class __slice_expr
    648 {
    649     typedef typename remove_reference<_ValExpr>::type  _RmExpr;
    650 public:
    651     typedef typename _RmExpr::value_type value_type;
    652     typedef value_type result_type;
    653 
    654 private:
    655     _ValExpr __expr_;
    656     size_t __start_;
    657     size_t __size_;
    658     size_t __stride_;
    659 
    660     _LIBCPP_INLINE_VISIBILITY
    661     __slice_expr(const slice& __sl, const _RmExpr& __e)
    662         : __expr_(__e),
    663           __start_(__sl.start()),
    664           __size_(__sl.size()),
    665           __stride_(__sl.stride())
    666         {}
    667 public:
    668 
    669     _LIBCPP_INLINE_VISIBILITY
    670     result_type operator[](size_t __i) const
    671         {return __expr_[__start_ + __i * __stride_];}
    672 
    673     _LIBCPP_INLINE_VISIBILITY
    674     size_t size() const {return __size_;}
    675 
    676     template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
    677 };
    678 
    679 template <class _ValExpr>
    680 class __mask_expr;
    681 
    682 template <class _ValExpr>
    683 class __indirect_expr;
    684 
    685 template <class _ValExpr>
    686 class __shift_expr
    687 {
    688     typedef typename remove_reference<_ValExpr>::type  _RmExpr;
    689 public:
    690     typedef typename _RmExpr::value_type value_type;
    691     typedef value_type result_type;
    692 
    693 private:
    694     _ValExpr __expr_;
    695     size_t __size_;
    696     ptrdiff_t __ul_;
    697     ptrdiff_t __sn_;
    698     ptrdiff_t __n_;
    699     static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
    700                                     sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
    701 
    702     _LIBCPP_INLINE_VISIBILITY
    703     __shift_expr(int __n, const _RmExpr& __e)
    704         : __expr_(__e),
    705           __size_(__e.size()),
    706           __n_(__n)
    707         {
    708             ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
    709             __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
    710             __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
    711         }
    712 public:
    713 
    714     _LIBCPP_INLINE_VISIBILITY
    715     result_type operator[](size_t __j) const
    716         {
    717             ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
    718             ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
    719             return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
    720         }
    721 
    722     _LIBCPP_INLINE_VISIBILITY
    723     size_t size() const {return __size_;}
    724 
    725     template <class> friend class __val_expr;
    726 };
    727 
    728 template <class _ValExpr>
    729 class __cshift_expr
    730 {
    731     typedef typename remove_reference<_ValExpr>::type  _RmExpr;
    732 public:
    733     typedef typename _RmExpr::value_type value_type;
    734     typedef value_type result_type;
    735 
    736 private:
    737     _ValExpr __expr_;
    738     size_t __size_;
    739     size_t __m_;
    740     size_t __o1_;
    741     size_t __o2_;
    742 
    743     _LIBCPP_INLINE_VISIBILITY
    744     __cshift_expr(int __n, const _RmExpr& __e)
    745         : __expr_(__e),
    746           __size_(__e.size())
    747         {
    748             __n %= static_cast<int>(__size_);
    749             if (__n >= 0)
    750             {
    751                 __m_ = __size_ - __n;
    752                 __o1_ = __n;
    753                 __o2_ = __n - __size_;
    754             }
    755             else
    756             {
    757                 __m_ = -__n;
    758                 __o1_ = __n + __size_;
    759                 __o2_ = __n;
    760             }
    761         }
    762 public:
    763 
    764     _LIBCPP_INLINE_VISIBILITY
    765     result_type operator[](size_t __i) const
    766         {
    767             if (__i < __m_)
    768                 return __expr_[__i + __o1_];
    769             return __expr_[__i + __o2_];
    770         }
    771 
    772     _LIBCPP_INLINE_VISIBILITY
    773     size_t size() const {return __size_;}
    774 
    775     template <class> friend class __val_expr;
    776 };
    777 
    778 template<class _ValExpr>
    779 class __val_expr;
    780 
    781 template<class _ValExpr>
    782 struct __is_val_expr : false_type {};
    783 
    784 template<class _ValExpr>
    785 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
    786 
    787 template<class _Tp>
    788 struct __is_val_expr<valarray<_Tp> > : true_type {};
    789 
    790 template<class _Tp>
    791 class _LIBCPP_TYPE_VIS_ONLY valarray
    792 {
    793 public:
    794     typedef _Tp value_type;
    795     typedef _Tp result_type;
    796 
    797 private:
    798     value_type* __begin_;
    799     value_type* __end_;
    800 
    801 public:
    802     // construct/destroy:
    803     _LIBCPP_INLINE_VISIBILITY
    804     valarray() : __begin_(0), __end_(0) {}
    805     _LIBCPP_INLINE_VISIBILITY
    806     inline explicit valarray(size_t __n);
    807     _LIBCPP_INLINE_VISIBILITY
    808     valarray(const value_type& __x, size_t __n);
    809     valarray(const value_type* __p, size_t __n);
    810     valarray(const valarray& __v);
    811 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    812     _LIBCPP_INLINE_VISIBILITY
    813     valarray(valarray&& __v) _NOEXCEPT;
    814 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
    815 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
    816     valarray(initializer_list<value_type> __il);
    817 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
    818     valarray(const slice_array<value_type>& __sa);
    819     valarray(const gslice_array<value_type>& __ga);
    820     valarray(const mask_array<value_type>& __ma);
    821     valarray(const indirect_array<value_type>& __ia);
    822     inline _LIBCPP_INLINE_VISIBILITY
    823     ~valarray();
    824 
    825     // assignment:
    826     valarray& operator=(const valarray& __v);
    827 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    828     _LIBCPP_INLINE_VISIBILITY
    829     valarray& operator=(valarray&& __v) _NOEXCEPT;
    830 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
    831 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
    832     _LIBCPP_INLINE_VISIBILITY
    833     valarray& operator=(initializer_list<value_type>);
    834 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
    835     _LIBCPP_INLINE_VISIBILITY
    836     valarray& operator=(const value_type& __x);
    837     _LIBCPP_INLINE_VISIBILITY
    838     valarray& operator=(const slice_array<value_type>& __sa);
    839     _LIBCPP_INLINE_VISIBILITY
    840     valarray& operator=(const gslice_array<value_type>& __ga);
    841     _LIBCPP_INLINE_VISIBILITY
    842     valarray& operator=(const mask_array<value_type>& __ma);
    843     _LIBCPP_INLINE_VISIBILITY
    844     valarray& operator=(const indirect_array<value_type>& __ia);
    845     template <class _ValExpr>
    846         _LIBCPP_INLINE_VISIBILITY
    847         valarray& operator=(const __val_expr<_ValExpr>& __v);
    848 
    849     // element access:
    850     _LIBCPP_INLINE_VISIBILITY
    851     const value_type& operator[](size_t __i) const {return __begin_[__i];}
    852 
    853     _LIBCPP_INLINE_VISIBILITY
    854     value_type&       operator[](size_t __i)       {return __begin_[__i];}
    855 
    856     // subset operations:
    857     _LIBCPP_INLINE_VISIBILITY
    858     __val_expr<__slice_expr<const valarray&> >    operator[](slice __s) const;
    859     _LIBCPP_INLINE_VISIBILITY
    860     slice_array<value_type>                       operator[](slice __s);
    861     _LIBCPP_INLINE_VISIBILITY
    862     __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
    863     _LIBCPP_INLINE_VISIBILITY
    864     gslice_array<value_type>   operator[](const gslice& __gs);
    865 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    866     _LIBCPP_INLINE_VISIBILITY
    867     __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
    868     _LIBCPP_INLINE_VISIBILITY
    869     gslice_array<value_type>                      operator[](gslice&& __gs);
    870 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
    871     _LIBCPP_INLINE_VISIBILITY
    872     __val_expr<__mask_expr<const valarray&> >     operator[](const valarray<bool>& __vb) const;
    873     _LIBCPP_INLINE_VISIBILITY
    874     mask_array<value_type>                        operator[](const valarray<bool>& __vb);
    875 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    876     _LIBCPP_INLINE_VISIBILITY
    877     __val_expr<__mask_expr<const valarray&> >     operator[](valarray<bool>&& __vb) const;
    878     _LIBCPP_INLINE_VISIBILITY
    879     mask_array<value_type>                        operator[](valarray<bool>&& __vb);
    880 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
    881     _LIBCPP_INLINE_VISIBILITY
    882     __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
    883     _LIBCPP_INLINE_VISIBILITY
    884     indirect_array<value_type>                    operator[](const valarray<size_t>& __vs);
    885 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    886     _LIBCPP_INLINE_VISIBILITY
    887     __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
    888     _LIBCPP_INLINE_VISIBILITY
    889     indirect_array<value_type>                    operator[](valarray<size_t>&& __vs);
    890 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
    891 
    892     // unary operators:
    893     valarray       operator+() const;
    894     valarray       operator-() const;
    895     valarray       operator~() const;
    896     valarray<bool> operator!() const;
    897 
    898     // computed assignment:
    899     _LIBCPP_INLINE_VISIBILITY
    900     valarray& operator*= (const value_type& __x);
    901     _LIBCPP_INLINE_VISIBILITY
    902     valarray& operator/= (const value_type& __x);
    903     _LIBCPP_INLINE_VISIBILITY
    904     valarray& operator%= (const value_type& __x);
    905     _LIBCPP_INLINE_VISIBILITY
    906     valarray& operator+= (const value_type& __x);
    907     _LIBCPP_INLINE_VISIBILITY
    908     valarray& operator-= (const value_type& __x);
    909     _LIBCPP_INLINE_VISIBILITY
    910     valarray& operator^= (const value_type& __x);
    911     _LIBCPP_INLINE_VISIBILITY
    912     valarray& operator&= (const value_type& __x);
    913     _LIBCPP_INLINE_VISIBILITY
    914     valarray& operator|= (const value_type& __x);
    915     _LIBCPP_INLINE_VISIBILITY
    916     valarray& operator<<=(const value_type& __x);
    917     _LIBCPP_INLINE_VISIBILITY
    918     valarray& operator>>=(const value_type& __x);
    919 
    920     template <class _Expr>
    921     typename enable_if
    922     <
    923         __is_val_expr<_Expr>::value,
    924         valarray&
    925     >::type
    926     _LIBCPP_INLINE_VISIBILITY
    927     operator*= (const _Expr& __v);
    928 
    929     template <class _Expr>
    930     typename enable_if
    931     <
    932         __is_val_expr<_Expr>::value,
    933         valarray&
    934     >::type
    935     _LIBCPP_INLINE_VISIBILITY
    936     operator/= (const _Expr& __v);
    937 
    938     template <class _Expr>
    939     typename enable_if
    940     <
    941         __is_val_expr<_Expr>::value,
    942         valarray&
    943     >::type
    944     _LIBCPP_INLINE_VISIBILITY
    945     operator%= (const _Expr& __v);
    946 
    947     template <class _Expr>
    948     typename enable_if
    949     <
    950         __is_val_expr<_Expr>::value,
    951         valarray&
    952     >::type
    953     _LIBCPP_INLINE_VISIBILITY
    954     operator+= (const _Expr& __v);
    955 
    956     template <class _Expr>
    957     typename enable_if
    958     <
    959         __is_val_expr<_Expr>::value,
    960         valarray&
    961     >::type
    962     _LIBCPP_INLINE_VISIBILITY
    963     operator-= (const _Expr& __v);
    964 
    965     template <class _Expr>
    966     typename enable_if
    967     <
    968         __is_val_expr<_Expr>::value,
    969         valarray&
    970     >::type
    971     _LIBCPP_INLINE_VISIBILITY
    972     operator^= (const _Expr& __v);
    973 
    974     template <class _Expr>
    975     typename enable_if
    976     <
    977         __is_val_expr<_Expr>::value,
    978         valarray&
    979     >::type
    980     _LIBCPP_INLINE_VISIBILITY
    981     operator|= (const _Expr& __v);
    982 
    983     template <class _Expr>
    984     typename enable_if
    985     <
    986         __is_val_expr<_Expr>::value,
    987         valarray&
    988     >::type
    989     _LIBCPP_INLINE_VISIBILITY
    990     operator&= (const _Expr& __v);
    991 
    992     template <class _Expr>
    993     typename enable_if
    994     <
    995         __is_val_expr<_Expr>::value,
    996         valarray&
    997     >::type
    998     _LIBCPP_INLINE_VISIBILITY
    999     operator<<= (const _Expr& __v);
   1000 
   1001     template <class _Expr>
   1002     typename enable_if
   1003     <
   1004         __is_val_expr<_Expr>::value,
   1005         valarray&
   1006     >::type
   1007     _LIBCPP_INLINE_VISIBILITY
   1008     operator>>= (const _Expr& __v);
   1009 
   1010     // member functions:
   1011     _LIBCPP_INLINE_VISIBILITY
   1012     void swap(valarray& __v) _NOEXCEPT;
   1013 
   1014     _LIBCPP_INLINE_VISIBILITY
   1015     size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
   1016 
   1017     _LIBCPP_INLINE_VISIBILITY
   1018     value_type sum() const;
   1019     _LIBCPP_INLINE_VISIBILITY
   1020     value_type min() const;
   1021     _LIBCPP_INLINE_VISIBILITY
   1022     value_type max() const;
   1023 
   1024     valarray shift (int __i) const;
   1025     valarray cshift(int __i) const;
   1026     valarray apply(value_type __f(value_type)) const;
   1027     valarray apply(value_type __f(const value_type&)) const;
   1028     void     resize(size_t __n, value_type __x = value_type());
   1029 
   1030 private:
   1031     template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
   1032     template <class> friend class _LIBCPP_TYPE_VIS_ONLY slice_array;
   1033     template <class> friend class _LIBCPP_TYPE_VIS_ONLY gslice_array;
   1034     template <class> friend class _LIBCPP_TYPE_VIS_ONLY mask_array;
   1035     template <class> friend class __mask_expr;
   1036     template <class> friend class _LIBCPP_TYPE_VIS_ONLY indirect_array;
   1037     template <class> friend class __indirect_expr;
   1038     template <class> friend class __val_expr;
   1039 
   1040     template <class _Up>
   1041     friend
   1042     _Up*
   1043     begin(valarray<_Up>& __v);
   1044 
   1045     template <class _Up>
   1046     friend
   1047     const _Up*
   1048     begin(const valarray<_Up>& __v);
   1049 
   1050     template <class _Up>
   1051     friend
   1052     _Up*
   1053     end(valarray<_Up>& __v);
   1054 
   1055     template <class _Up>
   1056     friend
   1057     const _Up*
   1058     end(const valarray<_Up>& __v);
   1059 };
   1060 
   1061 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
   1062 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
   1063 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
   1064 
   1065 template <class _Op, class _Tp>
   1066 struct _UnaryOp<_Op, valarray<_Tp> >
   1067 {
   1068     typedef typename _Op::result_type result_type;
   1069     typedef _Tp value_type;
   1070 
   1071     _Op __op_;
   1072     const valarray<_Tp>& __a0_;
   1073 
   1074     _LIBCPP_INLINE_VISIBILITY
   1075     _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
   1076 
   1077     _LIBCPP_INLINE_VISIBILITY
   1078     result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
   1079 
   1080     _LIBCPP_INLINE_VISIBILITY
   1081     size_t size() const {return __a0_.size();}
   1082 };
   1083 
   1084 template <class _Op, class _Tp, class _A1>
   1085 struct _BinaryOp<_Op, valarray<_Tp>, _A1>
   1086 {
   1087     typedef typename _Op::result_type result_type;
   1088     typedef _Tp value_type;
   1089 
   1090     _Op __op_;
   1091     const valarray<_Tp>& __a0_;
   1092     _A1 __a1_;
   1093 
   1094     _LIBCPP_INLINE_VISIBILITY
   1095     _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
   1096         : __op_(__op), __a0_(__a0), __a1_(__a1) {}
   1097 
   1098     _LIBCPP_INLINE_VISIBILITY
   1099     value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
   1100 
   1101     _LIBCPP_INLINE_VISIBILITY
   1102     size_t size() const {return __a0_.size();}
   1103 };
   1104 
   1105 template <class _Op, class _A0, class _Tp>
   1106 struct _BinaryOp<_Op, _A0, valarray<_Tp> >
   1107 {
   1108     typedef typename _Op::result_type result_type;
   1109     typedef _Tp value_type;
   1110 
   1111     _Op __op_;
   1112     _A0 __a0_;
   1113     const valarray<_Tp>& __a1_;
   1114 
   1115     _LIBCPP_INLINE_VISIBILITY
   1116     _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
   1117         : __op_(__op), __a0_(__a0), __a1_(__a1) {}
   1118 
   1119     _LIBCPP_INLINE_VISIBILITY
   1120     value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
   1121 
   1122     _LIBCPP_INLINE_VISIBILITY
   1123     size_t size() const {return __a0_.size();}
   1124 };
   1125 
   1126 template <class _Op, class _Tp>
   1127 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
   1128 {
   1129     typedef typename _Op::result_type result_type;
   1130     typedef _Tp value_type;
   1131 
   1132     _Op __op_;
   1133     const valarray<_Tp>& __a0_;
   1134     const valarray<_Tp>& __a1_;
   1135 
   1136     _LIBCPP_INLINE_VISIBILITY
   1137     _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
   1138         : __op_(__op), __a0_(__a0), __a1_(__a1) {}
   1139 
   1140     _LIBCPP_INLINE_VISIBILITY
   1141     value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
   1142 
   1143     _LIBCPP_INLINE_VISIBILITY
   1144     size_t size() const {return __a0_.size();}
   1145 };
   1146 
   1147 // slice_array
   1148 
   1149 template <class _Tp>
   1150 class _LIBCPP_TYPE_VIS_ONLY slice_array
   1151 {
   1152 public:
   1153     typedef _Tp value_type;
   1154 
   1155 private:
   1156     value_type* __vp_;
   1157     size_t __size_;
   1158     size_t __stride_;
   1159 
   1160 public:
   1161     template <class _Expr>
   1162     typename enable_if
   1163     <
   1164         __is_val_expr<_Expr>::value,
   1165         void
   1166     >::type
   1167     _LIBCPP_INLINE_VISIBILITY
   1168     operator=(const _Expr& __v) const;
   1169 
   1170     template <class _Expr>
   1171     typename enable_if
   1172     <
   1173         __is_val_expr<_Expr>::value,
   1174         void
   1175     >::type
   1176     _LIBCPP_INLINE_VISIBILITY
   1177     operator*=(const _Expr& __v) const;
   1178 
   1179     template <class _Expr>
   1180     typename enable_if
   1181     <
   1182         __is_val_expr<_Expr>::value,
   1183         void
   1184     >::type
   1185     _LIBCPP_INLINE_VISIBILITY
   1186     operator/=(const _Expr& __v) const;
   1187 
   1188     template <class _Expr>
   1189     typename enable_if
   1190     <
   1191         __is_val_expr<_Expr>::value,
   1192         void
   1193     >::type
   1194     _LIBCPP_INLINE_VISIBILITY
   1195     operator%=(const _Expr& __v) const;
   1196 
   1197     template <class _Expr>
   1198     typename enable_if
   1199     <
   1200         __is_val_expr<_Expr>::value,
   1201         void
   1202     >::type
   1203     _LIBCPP_INLINE_VISIBILITY
   1204     operator+=(const _Expr& __v) const;
   1205 
   1206     template <class _Expr>
   1207     typename enable_if
   1208     <
   1209         __is_val_expr<_Expr>::value,
   1210         void
   1211     >::type
   1212     _LIBCPP_INLINE_VISIBILITY
   1213     operator-=(const _Expr& __v) const;
   1214 
   1215     template <class _Expr>
   1216     typename enable_if
   1217     <
   1218         __is_val_expr<_Expr>::value,
   1219         void
   1220     >::type
   1221     _LIBCPP_INLINE_VISIBILITY
   1222     operator^=(const _Expr& __v) const;
   1223 
   1224     template <class _Expr>
   1225     typename enable_if
   1226     <
   1227         __is_val_expr<_Expr>::value,
   1228         void
   1229     >::type
   1230     _LIBCPP_INLINE_VISIBILITY
   1231     operator&=(const _Expr& __v) const;
   1232 
   1233     template <class _Expr>
   1234     typename enable_if
   1235     <
   1236         __is_val_expr<_Expr>::value,
   1237         void
   1238     >::type
   1239     _LIBCPP_INLINE_VISIBILITY
   1240     operator|=(const _Expr& __v) const;
   1241 
   1242     template <class _Expr>
   1243     typename enable_if
   1244     <
   1245         __is_val_expr<_Expr>::value,
   1246         void
   1247     >::type
   1248     _LIBCPP_INLINE_VISIBILITY
   1249     operator<<=(const _Expr& __v) const;
   1250 
   1251     template <class _Expr>
   1252     typename enable_if
   1253     <
   1254         __is_val_expr<_Expr>::value,
   1255         void
   1256     >::type
   1257     _LIBCPP_INLINE_VISIBILITY
   1258     operator>>=(const _Expr& __v) const;
   1259 
   1260     _LIBCPP_INLINE_VISIBILITY
   1261     const slice_array& operator=(const slice_array& __sa) const;
   1262 
   1263     _LIBCPP_INLINE_VISIBILITY
   1264     void operator=(const value_type& __x) const;
   1265 
   1266 private:
   1267     _LIBCPP_INLINE_VISIBILITY
   1268     slice_array(const slice& __sl, const valarray<value_type>& __v)
   1269         : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
   1270           __size_(__sl.size()),
   1271           __stride_(__sl.stride())
   1272         {}
   1273 
   1274     template <class> friend class valarray;
   1275     template <class> friend class sliceExpr;
   1276 };
   1277 
   1278 template <class _Tp>
   1279 inline
   1280 const slice_array<_Tp>&
   1281 slice_array<_Tp>::operator=(const slice_array& __sa) const
   1282 {
   1283     value_type* __t = __vp_;
   1284     const value_type* __s = __sa.__vp_;
   1285     for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
   1286         *__t = *__s;
   1287     return *this;
   1288 }
   1289 
   1290 template <class _Tp>
   1291 template <class _Expr>
   1292 inline
   1293 typename enable_if
   1294 <
   1295     __is_val_expr<_Expr>::value,
   1296     void
   1297 >::type
   1298 slice_array<_Tp>::operator=(const _Expr& __v) const
   1299 {
   1300     value_type* __t = __vp_;
   1301     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1302         *__t = __v[__i];
   1303 }
   1304 
   1305 template <class _Tp>
   1306 template <class _Expr>
   1307 inline
   1308 typename enable_if
   1309 <
   1310     __is_val_expr<_Expr>::value,
   1311     void
   1312 >::type
   1313 slice_array<_Tp>::operator*=(const _Expr& __v) const
   1314 {
   1315     value_type* __t = __vp_;
   1316     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1317         *__t *= __v[__i];
   1318 }
   1319 
   1320 template <class _Tp>
   1321 template <class _Expr>
   1322 inline
   1323 typename enable_if
   1324 <
   1325     __is_val_expr<_Expr>::value,
   1326     void
   1327 >::type
   1328 slice_array<_Tp>::operator/=(const _Expr& __v) const
   1329 {
   1330     value_type* __t = __vp_;
   1331     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1332         *__t /= __v[__i];
   1333 }
   1334 
   1335 template <class _Tp>
   1336 template <class _Expr>
   1337 inline
   1338 typename enable_if
   1339 <
   1340     __is_val_expr<_Expr>::value,
   1341     void
   1342 >::type
   1343 slice_array<_Tp>::operator%=(const _Expr& __v) const
   1344 {
   1345     value_type* __t = __vp_;
   1346     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1347         *__t %= __v[__i];
   1348 }
   1349 
   1350 template <class _Tp>
   1351 template <class _Expr>
   1352 inline
   1353 typename enable_if
   1354 <
   1355     __is_val_expr<_Expr>::value,
   1356     void
   1357 >::type
   1358 slice_array<_Tp>::operator+=(const _Expr& __v) const
   1359 {
   1360     value_type* __t = __vp_;
   1361     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1362         *__t += __v[__i];
   1363 }
   1364 
   1365 template <class _Tp>
   1366 template <class _Expr>
   1367 inline
   1368 typename enable_if
   1369 <
   1370     __is_val_expr<_Expr>::value,
   1371     void
   1372 >::type
   1373 slice_array<_Tp>::operator-=(const _Expr& __v) const
   1374 {
   1375     value_type* __t = __vp_;
   1376     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1377         *__t -= __v[__i];
   1378 }
   1379 
   1380 template <class _Tp>
   1381 template <class _Expr>
   1382 inline
   1383 typename enable_if
   1384 <
   1385     __is_val_expr<_Expr>::value,
   1386     void
   1387 >::type
   1388 slice_array<_Tp>::operator^=(const _Expr& __v) const
   1389 {
   1390     value_type* __t = __vp_;
   1391     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1392         *__t ^= __v[__i];
   1393 }
   1394 
   1395 template <class _Tp>
   1396 template <class _Expr>
   1397 inline
   1398 typename enable_if
   1399 <
   1400     __is_val_expr<_Expr>::value,
   1401     void
   1402 >::type
   1403 slice_array<_Tp>::operator&=(const _Expr& __v) const
   1404 {
   1405     value_type* __t = __vp_;
   1406     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1407         *__t &= __v[__i];
   1408 }
   1409 
   1410 template <class _Tp>
   1411 template <class _Expr>
   1412 inline
   1413 typename enable_if
   1414 <
   1415     __is_val_expr<_Expr>::value,
   1416     void
   1417 >::type
   1418 slice_array<_Tp>::operator|=(const _Expr& __v) const
   1419 {
   1420     value_type* __t = __vp_;
   1421     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1422         *__t |= __v[__i];
   1423 }
   1424 
   1425 template <class _Tp>
   1426 template <class _Expr>
   1427 inline
   1428 typename enable_if
   1429 <
   1430     __is_val_expr<_Expr>::value,
   1431     void
   1432 >::type
   1433 slice_array<_Tp>::operator<<=(const _Expr& __v) const
   1434 {
   1435     value_type* __t = __vp_;
   1436     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1437         *__t <<= __v[__i];
   1438 }
   1439 
   1440 template <class _Tp>
   1441 template <class _Expr>
   1442 inline
   1443 typename enable_if
   1444 <
   1445     __is_val_expr<_Expr>::value,
   1446     void
   1447 >::type
   1448 slice_array<_Tp>::operator>>=(const _Expr& __v) const
   1449 {
   1450     value_type* __t = __vp_;
   1451     for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
   1452         *__t >>= __v[__i];
   1453 }
   1454 
   1455 template <class _Tp>
   1456 inline
   1457 void
   1458 slice_array<_Tp>::operator=(const value_type& __x) const
   1459 {
   1460     value_type* __t = __vp_;
   1461     for (size_t __n = __size_; __n; --__n, __t += __stride_)
   1462         *__t = __x;
   1463 }
   1464 
   1465 // gslice
   1466 
   1467 class _LIBCPP_TYPE_VIS gslice
   1468 {
   1469     valarray<size_t> __size_;
   1470     valarray<size_t> __stride_;
   1471     valarray<size_t> __1d_;
   1472 
   1473 public:
   1474     _LIBCPP_INLINE_VISIBILITY
   1475     gslice() {}
   1476 
   1477     _LIBCPP_INLINE_VISIBILITY
   1478     gslice(size_t __start, const valarray<size_t>& __size,
   1479                            const valarray<size_t>& __stride)
   1480         : __size_(__size),
   1481           __stride_(__stride)
   1482         {__init(__start);}
   1483 
   1484 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1485 
   1486     _LIBCPP_INLINE_VISIBILITY
   1487     gslice(size_t __start, const valarray<size_t>&  __size,
   1488                                  valarray<size_t>&& __stride)
   1489         : __size_(__size),
   1490           __stride_(move(__stride))
   1491         {__init(__start);}
   1492 
   1493     _LIBCPP_INLINE_VISIBILITY
   1494     gslice(size_t __start,       valarray<size_t>&& __size,
   1495                            const valarray<size_t>&  __stride)
   1496         : __size_(move(__size)),
   1497           __stride_(__stride)
   1498         {__init(__start);}
   1499 
   1500     _LIBCPP_INLINE_VISIBILITY
   1501     gslice(size_t __start,       valarray<size_t>&& __size,
   1502                                  valarray<size_t>&& __stride)
   1503         : __size_(move(__size)),
   1504           __stride_(move(__stride))
   1505         {__init(__start);}
   1506 
   1507 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1508 
   1509 //  gslice(const gslice&)            = default;
   1510 //  gslice(gslice&&)                 = default;
   1511 //  gslice& operator=(const gslice&) = default;
   1512 //  gslice& operator=(gslice&&)      = default;
   1513 
   1514     _LIBCPP_INLINE_VISIBILITY
   1515     size_t           start()  const {return __1d_.size() ? __1d_[0] : 0;}
   1516 
   1517     _LIBCPP_INLINE_VISIBILITY
   1518     valarray<size_t> size()   const {return __size_;}
   1519 
   1520     _LIBCPP_INLINE_VISIBILITY
   1521     valarray<size_t> stride() const {return __stride_;}
   1522 
   1523 private:
   1524     void __init(size_t __start);
   1525 
   1526     template <class> friend class gslice_array;
   1527     template <class> friend class valarray;
   1528     template <class> friend class __val_expr;
   1529 };
   1530 
   1531 // gslice_array
   1532 
   1533 template <class _Tp>
   1534 class _LIBCPP_TYPE_VIS_ONLY gslice_array
   1535 {
   1536 public:
   1537     typedef _Tp value_type;
   1538 
   1539 private:
   1540     value_type*      __vp_;
   1541     valarray<size_t> __1d_;
   1542 
   1543 public:
   1544     template <class _Expr>
   1545     typename enable_if
   1546     <
   1547         __is_val_expr<_Expr>::value,
   1548         void
   1549     >::type
   1550     _LIBCPP_INLINE_VISIBILITY
   1551     operator=(const _Expr& __v) const;
   1552 
   1553     template <class _Expr>
   1554     typename enable_if
   1555     <
   1556         __is_val_expr<_Expr>::value,
   1557         void
   1558     >::type
   1559     _LIBCPP_INLINE_VISIBILITY
   1560     operator*=(const _Expr& __v) const;
   1561 
   1562     template <class _Expr>
   1563     typename enable_if
   1564     <
   1565         __is_val_expr<_Expr>::value,
   1566         void
   1567     >::type
   1568     _LIBCPP_INLINE_VISIBILITY
   1569     operator/=(const _Expr& __v) const;
   1570 
   1571     template <class _Expr>
   1572     typename enable_if
   1573     <
   1574         __is_val_expr<_Expr>::value,
   1575         void
   1576     >::type
   1577     _LIBCPP_INLINE_VISIBILITY
   1578     operator%=(const _Expr& __v) const;
   1579 
   1580     template <class _Expr>
   1581     typename enable_if
   1582     <
   1583         __is_val_expr<_Expr>::value,
   1584         void
   1585     >::type
   1586     _LIBCPP_INLINE_VISIBILITY
   1587     operator+=(const _Expr& __v) const;
   1588 
   1589     template <class _Expr>
   1590     typename enable_if
   1591     <
   1592         __is_val_expr<_Expr>::value,
   1593         void
   1594     >::type
   1595     _LIBCPP_INLINE_VISIBILITY
   1596     operator-=(const _Expr& __v) const;
   1597 
   1598     template <class _Expr>
   1599     typename enable_if
   1600     <
   1601         __is_val_expr<_Expr>::value,
   1602         void
   1603     >::type
   1604     _LIBCPP_INLINE_VISIBILITY
   1605     operator^=(const _Expr& __v) const;
   1606 
   1607     template <class _Expr>
   1608     typename enable_if
   1609     <
   1610         __is_val_expr<_Expr>::value,
   1611         void
   1612     >::type
   1613     _LIBCPP_INLINE_VISIBILITY
   1614     operator&=(const _Expr& __v) const;
   1615 
   1616     template <class _Expr>
   1617     typename enable_if
   1618     <
   1619         __is_val_expr<_Expr>::value,
   1620         void
   1621     >::type
   1622     _LIBCPP_INLINE_VISIBILITY
   1623     operator|=(const _Expr& __v) const;
   1624 
   1625     template <class _Expr>
   1626     typename enable_if
   1627     <
   1628         __is_val_expr<_Expr>::value,
   1629         void
   1630     >::type
   1631     _LIBCPP_INLINE_VISIBILITY
   1632     operator<<=(const _Expr& __v) const;
   1633 
   1634     template <class _Expr>
   1635     typename enable_if
   1636     <
   1637         __is_val_expr<_Expr>::value,
   1638         void
   1639     >::type
   1640     _LIBCPP_INLINE_VISIBILITY
   1641     operator>>=(const _Expr& __v) const;
   1642 
   1643     _LIBCPP_INLINE_VISIBILITY
   1644     const gslice_array& operator=(const gslice_array& __ga) const;
   1645 
   1646     _LIBCPP_INLINE_VISIBILITY
   1647     void operator=(const value_type& __x) const;
   1648 
   1649 //  gslice_array(const gslice_array&)            = default;
   1650 //  gslice_array(gslice_array&&)                 = default;
   1651 //  gslice_array& operator=(const gslice_array&) = default;
   1652 //  gslice_array& operator=(gslice_array&&)      = default;
   1653 
   1654 private:
   1655     gslice_array(const gslice& __gs, const valarray<value_type>& __v)
   1656         : __vp_(const_cast<value_type*>(__v.__begin_)),
   1657           __1d_(__gs.__1d_)
   1658         {}
   1659 
   1660 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1661     gslice_array(gslice&& __gs, const valarray<value_type>& __v)
   1662         : __vp_(const_cast<value_type*>(__v.__begin_)),
   1663           __1d_(move(__gs.__1d_))
   1664         {}
   1665 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   1666 
   1667     template <class> friend class valarray;
   1668 };
   1669 
   1670 template <class _Tp>
   1671 template <class _Expr>
   1672 inline
   1673 typename enable_if
   1674 <
   1675     __is_val_expr<_Expr>::value,
   1676     void
   1677 >::type
   1678 gslice_array<_Tp>::operator=(const _Expr& __v) const
   1679 {
   1680     typedef const size_t* _Ip;
   1681     size_t __j = 0;
   1682     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1683         __vp_[*__i] = __v[__j];
   1684 }
   1685 
   1686 template <class _Tp>
   1687 template <class _Expr>
   1688 inline
   1689 typename enable_if
   1690 <
   1691     __is_val_expr<_Expr>::value,
   1692     void
   1693 >::type
   1694 gslice_array<_Tp>::operator*=(const _Expr& __v) const
   1695 {
   1696     typedef const size_t* _Ip;
   1697     size_t __j = 0;
   1698     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1699         __vp_[*__i] *= __v[__j];
   1700 }
   1701 
   1702 template <class _Tp>
   1703 template <class _Expr>
   1704 inline
   1705 typename enable_if
   1706 <
   1707     __is_val_expr<_Expr>::value,
   1708     void
   1709 >::type
   1710 gslice_array<_Tp>::operator/=(const _Expr& __v) const
   1711 {
   1712     typedef const size_t* _Ip;
   1713     size_t __j = 0;
   1714     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1715         __vp_[*__i] /= __v[__j];
   1716 }
   1717 
   1718 template <class _Tp>
   1719 template <class _Expr>
   1720 inline
   1721 typename enable_if
   1722 <
   1723     __is_val_expr<_Expr>::value,
   1724     void
   1725 >::type
   1726 gslice_array<_Tp>::operator%=(const _Expr& __v) const
   1727 {
   1728     typedef const size_t* _Ip;
   1729     size_t __j = 0;
   1730     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1731         __vp_[*__i] %= __v[__j];
   1732 }
   1733 
   1734 template <class _Tp>
   1735 template <class _Expr>
   1736 inline
   1737 typename enable_if
   1738 <
   1739     __is_val_expr<_Expr>::value,
   1740     void
   1741 >::type
   1742 gslice_array<_Tp>::operator+=(const _Expr& __v) const
   1743 {
   1744     typedef const size_t* _Ip;
   1745     size_t __j = 0;
   1746     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1747         __vp_[*__i] += __v[__j];
   1748 }
   1749 
   1750 template <class _Tp>
   1751 template <class _Expr>
   1752 inline
   1753 typename enable_if
   1754 <
   1755     __is_val_expr<_Expr>::value,
   1756     void
   1757 >::type
   1758 gslice_array<_Tp>::operator-=(const _Expr& __v) const
   1759 {
   1760     typedef const size_t* _Ip;
   1761     size_t __j = 0;
   1762     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1763         __vp_[*__i] -= __v[__j];
   1764 }
   1765 
   1766 template <class _Tp>
   1767 template <class _Expr>
   1768 inline
   1769 typename enable_if
   1770 <
   1771     __is_val_expr<_Expr>::value,
   1772     void
   1773 >::type
   1774 gslice_array<_Tp>::operator^=(const _Expr& __v) const
   1775 {
   1776     typedef const size_t* _Ip;
   1777     size_t __j = 0;
   1778     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1779         __vp_[*__i] ^= __v[__j];
   1780 }
   1781 
   1782 template <class _Tp>
   1783 template <class _Expr>
   1784 inline
   1785 typename enable_if
   1786 <
   1787     __is_val_expr<_Expr>::value,
   1788     void
   1789 >::type
   1790 gslice_array<_Tp>::operator&=(const _Expr& __v) const
   1791 {
   1792     typedef const size_t* _Ip;
   1793     size_t __j = 0;
   1794     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1795         __vp_[*__i] &= __v[__j];
   1796 }
   1797 
   1798 template <class _Tp>
   1799 template <class _Expr>
   1800 inline
   1801 typename enable_if
   1802 <
   1803     __is_val_expr<_Expr>::value,
   1804     void
   1805 >::type
   1806 gslice_array<_Tp>::operator|=(const _Expr& __v) const
   1807 {
   1808     typedef const size_t* _Ip;
   1809     size_t __j = 0;
   1810     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1811         __vp_[*__i] |= __v[__j];
   1812 }
   1813 
   1814 template <class _Tp>
   1815 template <class _Expr>
   1816 inline
   1817 typename enable_if
   1818 <
   1819     __is_val_expr<_Expr>::value,
   1820     void
   1821 >::type
   1822 gslice_array<_Tp>::operator<<=(const _Expr& __v) const
   1823 {
   1824     typedef const size_t* _Ip;
   1825     size_t __j = 0;
   1826     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1827         __vp_[*__i] <<= __v[__j];
   1828 }
   1829 
   1830 template <class _Tp>
   1831 template <class _Expr>
   1832 inline
   1833 typename enable_if
   1834 <
   1835     __is_val_expr<_Expr>::value,
   1836     void
   1837 >::type
   1838 gslice_array<_Tp>::operator>>=(const _Expr& __v) const
   1839 {
   1840     typedef const size_t* _Ip;
   1841     size_t __j = 0;
   1842     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
   1843         __vp_[*__i] >>= __v[__j];
   1844 }
   1845 
   1846 template <class _Tp>
   1847 inline
   1848 const gslice_array<_Tp>&
   1849 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
   1850 {
   1851     typedef const size_t* _Ip;
   1852     const value_type* __s = __ga.__vp_;
   1853     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
   1854             __i != __e; ++__i, ++__j)
   1855         __vp_[*__i] = __s[*__j];
   1856     return *this;
   1857 }
   1858 
   1859 template <class _Tp>
   1860 inline
   1861 void
   1862 gslice_array<_Tp>::operator=(const value_type& __x) const
   1863 {
   1864     typedef const size_t* _Ip;
   1865     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
   1866         __vp_[*__i] = __x;
   1867 }
   1868 
   1869 // mask_array
   1870 
   1871 template <class _Tp>
   1872 class _LIBCPP_TYPE_VIS_ONLY mask_array
   1873 {
   1874 public:
   1875     typedef _Tp value_type;
   1876 
   1877 private:
   1878     value_type*      __vp_;
   1879     valarray<size_t> __1d_;
   1880 
   1881 public:
   1882     template <class _Expr>
   1883     typename enable_if
   1884     <
   1885         __is_val_expr<_Expr>::value,
   1886         void
   1887     >::type
   1888     _LIBCPP_INLINE_VISIBILITY
   1889     operator=(const _Expr& __v) const;
   1890 
   1891     template <class _Expr>
   1892     typename enable_if
   1893     <
   1894         __is_val_expr<_Expr>::value,
   1895         void
   1896     >::type
   1897     _LIBCPP_INLINE_VISIBILITY
   1898     operator*=(const _Expr& __v) const;
   1899 
   1900     template <class _Expr>
   1901     typename enable_if
   1902     <
   1903         __is_val_expr<_Expr>::value,
   1904         void
   1905     >::type
   1906     _LIBCPP_INLINE_VISIBILITY
   1907     operator/=(const _Expr& __v) const;
   1908 
   1909     template <class _Expr>
   1910     typename enable_if
   1911     <
   1912         __is_val_expr<_Expr>::value,
   1913         void
   1914     >::type
   1915     _LIBCPP_INLINE_VISIBILITY
   1916     operator%=(const _Expr& __v) const;
   1917 
   1918     template <class _Expr>
   1919     typename enable_if
   1920     <
   1921         __is_val_expr<_Expr>::value,
   1922         void
   1923     >::type
   1924     _LIBCPP_INLINE_VISIBILITY
   1925     operator+=(const _Expr& __v) const;
   1926 
   1927     template <class _Expr>
   1928     typename enable_if
   1929     <
   1930         __is_val_expr<_Expr>::value,
   1931         void
   1932     >::type
   1933     _LIBCPP_INLINE_VISIBILITY
   1934     operator-=(const _Expr& __v) const;
   1935 
   1936     template <class _Expr>
   1937     typename enable_if
   1938     <
   1939         __is_val_expr<_Expr>::value,
   1940         void
   1941     >::type
   1942     _LIBCPP_INLINE_VISIBILITY
   1943     operator^=(const _Expr& __v) const;
   1944 
   1945     template <class _Expr>
   1946     typename enable_if
   1947     <
   1948         __is_val_expr<_Expr>::value,
   1949         void
   1950     >::type
   1951     _LIBCPP_INLINE_VISIBILITY
   1952     operator&=(const _Expr& __v) const;
   1953 
   1954     template <class _Expr>
   1955     typename enable_if
   1956     <
   1957         __is_val_expr<_Expr>::value,
   1958         void
   1959     >::type
   1960     _LIBCPP_INLINE_VISIBILITY
   1961     operator|=(const _Expr& __v) const;
   1962 
   1963     template <class _Expr>
   1964     typename enable_if
   1965     <
   1966         __is_val_expr<_Expr>::value,
   1967         void
   1968     >::type
   1969     _LIBCPP_INLINE_VISIBILITY
   1970     operator<<=(const _Expr& __v) const;
   1971 
   1972     template <class _Expr>
   1973     typename enable_if
   1974     <
   1975         __is_val_expr<_Expr>::value,
   1976         void
   1977     >::type
   1978     _LIBCPP_INLINE_VISIBILITY
   1979     operator>>=(const _Expr& __v) const;
   1980 
   1981     _LIBCPP_INLINE_VISIBILITY
   1982     const mask_array& operator=(const mask_array& __ma) const;
   1983 
   1984     _LIBCPP_INLINE_VISIBILITY
   1985     void operator=(const value_type& __x) const;
   1986 
   1987 //  mask_array(const mask_array&)            = default;
   1988 //  mask_array(mask_array&&)                 = default;
   1989 //  mask_array& operator=(const mask_array&) = default;
   1990 //  mask_array& operator=(mask_array&&)      = default;
   1991 
   1992 private:
   1993     _LIBCPP_INLINE_VISIBILITY
   1994     mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
   1995         : __vp_(const_cast<value_type*>(__v.__begin_)),
   1996           __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
   1997           {
   1998               size_t __j = 0;
   1999               for (size_t __i = 0; __i < __vb.size(); ++__i)
   2000                   if (__vb[__i])
   2001                       __1d_[__j++] = __i;
   2002           }
   2003 
   2004     template <class> friend class valarray;
   2005 };
   2006 
   2007 template <class _Tp>
   2008 template <class _Expr>
   2009 inline
   2010 typename enable_if
   2011 <
   2012     __is_val_expr<_Expr>::value,
   2013     void
   2014 >::type
   2015 mask_array<_Tp>::operator=(const _Expr& __v) const
   2016 {
   2017     size_t __n = __1d_.size();
   2018     for (size_t __i = 0; __i < __n; ++__i)
   2019         __vp_[__1d_[__i]] = __v[__i];
   2020 }
   2021 
   2022 template <class _Tp>
   2023 template <class _Expr>
   2024 inline
   2025 typename enable_if
   2026 <
   2027     __is_val_expr<_Expr>::value,
   2028     void
   2029 >::type
   2030 mask_array<_Tp>::operator*=(const _Expr& __v) const
   2031 {
   2032     size_t __n = __1d_.size();
   2033     for (size_t __i = 0; __i < __n; ++__i)
   2034         __vp_[__1d_[__i]] *= __v[__i];
   2035 }
   2036 
   2037 template <class _Tp>
   2038 template <class _Expr>
   2039 inline
   2040 typename enable_if
   2041 <
   2042     __is_val_expr<_Expr>::value,
   2043     void
   2044 >::type
   2045 mask_array<_Tp>::operator/=(const _Expr& __v) const
   2046 {
   2047     size_t __n = __1d_.size();
   2048     for (size_t __i = 0; __i < __n; ++__i)
   2049         __vp_[__1d_[__i]] /= __v[__i];
   2050 }
   2051 
   2052 template <class _Tp>
   2053 template <class _Expr>
   2054 inline
   2055 typename enable_if
   2056 <
   2057     __is_val_expr<_Expr>::value,
   2058     void
   2059 >::type
   2060 mask_array<_Tp>::operator%=(const _Expr& __v) const
   2061 {
   2062     size_t __n = __1d_.size();
   2063     for (size_t __i = 0; __i < __n; ++__i)
   2064         __vp_[__1d_[__i]] %= __v[__i];
   2065 }
   2066 
   2067 template <class _Tp>
   2068 template <class _Expr>
   2069 inline
   2070 typename enable_if
   2071 <
   2072     __is_val_expr<_Expr>::value,
   2073     void
   2074 >::type
   2075 mask_array<_Tp>::operator+=(const _Expr& __v) const
   2076 {
   2077     size_t __n = __1d_.size();
   2078     for (size_t __i = 0; __i < __n; ++__i)
   2079         __vp_[__1d_[__i]] += __v[__i];
   2080 }
   2081 
   2082 template <class _Tp>
   2083 template <class _Expr>
   2084 inline
   2085 typename enable_if
   2086 <
   2087     __is_val_expr<_Expr>::value,
   2088     void
   2089 >::type
   2090 mask_array<_Tp>::operator-=(const _Expr& __v) const
   2091 {
   2092     size_t __n = __1d_.size();
   2093     for (size_t __i = 0; __i < __n; ++__i)
   2094         __vp_[__1d_[__i]] -= __v[__i];
   2095 }
   2096 
   2097 template <class _Tp>
   2098 template <class _Expr>
   2099 inline
   2100 typename enable_if
   2101 <
   2102     __is_val_expr<_Expr>::value,
   2103     void
   2104 >::type
   2105 mask_array<_Tp>::operator^=(const _Expr& __v) const
   2106 {
   2107     size_t __n = __1d_.size();
   2108     for (size_t __i = 0; __i < __n; ++__i)
   2109         __vp_[__1d_[__i]] ^= __v[__i];
   2110 }
   2111 
   2112 template <class _Tp>
   2113 template <class _Expr>
   2114 inline
   2115 typename enable_if
   2116 <
   2117     __is_val_expr<_Expr>::value,
   2118     void
   2119 >::type
   2120 mask_array<_Tp>::operator&=(const _Expr& __v) const
   2121 {
   2122     size_t __n = __1d_.size();
   2123     for (size_t __i = 0; __i < __n; ++__i)
   2124         __vp_[__1d_[__i]] &= __v[__i];
   2125 }
   2126 
   2127 template <class _Tp>
   2128 template <class _Expr>
   2129 inline
   2130 typename enable_if
   2131 <
   2132     __is_val_expr<_Expr>::value,
   2133     void
   2134 >::type
   2135 mask_array<_Tp>::operator|=(const _Expr& __v) const
   2136 {
   2137     size_t __n = __1d_.size();
   2138     for (size_t __i = 0; __i < __n; ++__i)
   2139         __vp_[__1d_[__i]] |= __v[__i];
   2140 }
   2141 
   2142 template <class _Tp>
   2143 template <class _Expr>
   2144 inline
   2145 typename enable_if
   2146 <
   2147     __is_val_expr<_Expr>::value,
   2148     void
   2149 >::type
   2150 mask_array<_Tp>::operator<<=(const _Expr& __v) const
   2151 {
   2152     size_t __n = __1d_.size();
   2153     for (size_t __i = 0; __i < __n; ++__i)
   2154         __vp_[__1d_[__i]] <<= __v[__i];
   2155 }
   2156 
   2157 template <class _Tp>
   2158 template <class _Expr>
   2159 inline
   2160 typename enable_if
   2161 <
   2162     __is_val_expr<_Expr>::value,
   2163     void
   2164 >::type
   2165 mask_array<_Tp>::operator>>=(const _Expr& __v) const
   2166 {
   2167     size_t __n = __1d_.size();
   2168     for (size_t __i = 0; __i < __n; ++__i)
   2169         __vp_[__1d_[__i]] >>= __v[__i];
   2170 }
   2171 
   2172 template <class _Tp>
   2173 inline
   2174 const mask_array<_Tp>&
   2175 mask_array<_Tp>::operator=(const mask_array& __ma) const
   2176 {
   2177     size_t __n = __1d_.size();
   2178     for (size_t __i = 0; __i < __n; ++__i)
   2179         __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
   2180     return *this;
   2181 }
   2182 
   2183 template <class _Tp>
   2184 inline
   2185 void
   2186 mask_array<_Tp>::operator=(const value_type& __x) const
   2187 {
   2188     size_t __n = __1d_.size();
   2189     for (size_t __i = 0; __i < __n; ++__i)
   2190         __vp_[__1d_[__i]] = __x;
   2191 }
   2192 
   2193 template <class _ValExpr>
   2194 class __mask_expr
   2195 {
   2196     typedef typename remove_reference<_ValExpr>::type  _RmExpr;
   2197 public:
   2198     typedef typename _RmExpr::value_type value_type;
   2199     typedef value_type result_type;
   2200 
   2201 private:
   2202     _ValExpr __expr_;
   2203     valarray<size_t> __1d_;
   2204 
   2205     _LIBCPP_INLINE_VISIBILITY
   2206     __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
   2207         : __expr_(__e),
   2208           __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
   2209           {
   2210               size_t __j = 0;
   2211               for (size_t __i = 0; __i < __vb.size(); ++__i)
   2212                   if (__vb[__i])
   2213                       __1d_[__j++] = __i;
   2214           }
   2215 
   2216 public:
   2217     _LIBCPP_INLINE_VISIBILITY
   2218     result_type operator[](size_t __i) const
   2219         {return __expr_[__1d_[__i]];}
   2220 
   2221     _LIBCPP_INLINE_VISIBILITY
   2222     size_t size() const {return __1d_.size();}
   2223 
   2224     template <class> friend class valarray;
   2225 };
   2226 
   2227 // indirect_array
   2228 
   2229 template <class _Tp>
   2230 class _LIBCPP_TYPE_VIS_ONLY indirect_array
   2231 {
   2232 public:
   2233     typedef _Tp value_type;
   2234 
   2235 private:
   2236     value_type*      __vp_;
   2237     valarray<size_t> __1d_;
   2238 
   2239 public:
   2240     template <class _Expr>
   2241     typename enable_if
   2242     <
   2243         __is_val_expr<_Expr>::value,
   2244         void
   2245     >::type
   2246     _LIBCPP_INLINE_VISIBILITY
   2247     operator=(const _Expr& __v) const;
   2248 
   2249     template <class _Expr>
   2250     typename enable_if
   2251     <
   2252         __is_val_expr<_Expr>::value,
   2253         void
   2254     >::type
   2255     _LIBCPP_INLINE_VISIBILITY
   2256     operator*=(const _Expr& __v) const;
   2257 
   2258     template <class _Expr>
   2259     typename enable_if
   2260     <
   2261         __is_val_expr<_Expr>::value,
   2262         void
   2263     >::type
   2264     _LIBCPP_INLINE_VISIBILITY
   2265     operator/=(const _Expr& __v) const;
   2266 
   2267     template <class _Expr>
   2268     typename enable_if
   2269     <
   2270         __is_val_expr<_Expr>::value,
   2271         void
   2272     >::type
   2273     _LIBCPP_INLINE_VISIBILITY
   2274     operator%=(const _Expr& __v) const;
   2275 
   2276     template <class _Expr>
   2277     typename enable_if
   2278     <
   2279         __is_val_expr<_Expr>::value,
   2280         void
   2281     >::type
   2282     _LIBCPP_INLINE_VISIBILITY
   2283     operator+=(const _Expr& __v) const;
   2284 
   2285     template <class _Expr>
   2286     typename enable_if
   2287     <
   2288         __is_val_expr<_Expr>::value,
   2289         void
   2290     >::type
   2291     _LIBCPP_INLINE_VISIBILITY
   2292     operator-=(const _Expr& __v) const;
   2293 
   2294     template <class _Expr>
   2295     typename enable_if
   2296     <
   2297         __is_val_expr<_Expr>::value,
   2298         void
   2299     >::type
   2300     _LIBCPP_INLINE_VISIBILITY
   2301     operator^=(const _Expr& __v) const;
   2302 
   2303     template <class _Expr>
   2304     typename enable_if
   2305     <
   2306         __is_val_expr<_Expr>::value,
   2307         void
   2308     >::type
   2309     _LIBCPP_INLINE_VISIBILITY
   2310     operator&=(const _Expr& __v) const;
   2311 
   2312     template <class _Expr>
   2313     typename enable_if
   2314     <
   2315         __is_val_expr<_Expr>::value,
   2316         void
   2317     >::type
   2318     _LIBCPP_INLINE_VISIBILITY
   2319     operator|=(const _Expr& __v) const;
   2320 
   2321     template <class _Expr>
   2322     typename enable_if
   2323     <
   2324         __is_val_expr<_Expr>::value,
   2325         void
   2326     >::type
   2327     _LIBCPP_INLINE_VISIBILITY
   2328     operator<<=(const _Expr& __v) const;
   2329 
   2330     template <class _Expr>
   2331     typename enable_if
   2332     <
   2333         __is_val_expr<_Expr>::value,
   2334         void
   2335     >::type
   2336     _LIBCPP_INLINE_VISIBILITY
   2337     operator>>=(const _Expr& __v) const;
   2338 
   2339     _LIBCPP_INLINE_VISIBILITY
   2340     const indirect_array& operator=(const indirect_array& __ia) const;
   2341 
   2342     _LIBCPP_INLINE_VISIBILITY
   2343     void operator=(const value_type& __x) const;
   2344 
   2345 //  indirect_array(const indirect_array&)            = default;
   2346 //  indirect_array(indirect_array&&)                 = default;
   2347 //  indirect_array& operator=(const indirect_array&) = default;
   2348 //  indirect_array& operator=(indirect_array&&)      = default;
   2349 
   2350 private:
   2351      _LIBCPP_INLINE_VISIBILITY
   2352    indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
   2353         : __vp_(const_cast<value_type*>(__v.__begin_)),
   2354           __1d_(__ia)
   2355         {}
   2356 
   2357 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2358 
   2359     _LIBCPP_INLINE_VISIBILITY
   2360     indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
   2361         : __vp_(const_cast<value_type*>(__v.__begin_)),
   2362           __1d_(move(__ia))
   2363         {}
   2364 
   2365 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2366 
   2367     template <class> friend class valarray;
   2368 };
   2369 
   2370 template <class _Tp>
   2371 template <class _Expr>
   2372 inline
   2373 typename enable_if
   2374 <
   2375     __is_val_expr<_Expr>::value,
   2376     void
   2377 >::type
   2378 indirect_array<_Tp>::operator=(const _Expr& __v) const
   2379 {
   2380     size_t __n = __1d_.size();
   2381     for (size_t __i = 0; __i < __n; ++__i)
   2382         __vp_[__1d_[__i]] = __v[__i];
   2383 }
   2384 
   2385 template <class _Tp>
   2386 template <class _Expr>
   2387 inline
   2388 typename enable_if
   2389 <
   2390     __is_val_expr<_Expr>::value,
   2391     void
   2392 >::type
   2393 indirect_array<_Tp>::operator*=(const _Expr& __v) const
   2394 {
   2395     size_t __n = __1d_.size();
   2396     for (size_t __i = 0; __i < __n; ++__i)
   2397         __vp_[__1d_[__i]] *= __v[__i];
   2398 }
   2399 
   2400 template <class _Tp>
   2401 template <class _Expr>
   2402 inline
   2403 typename enable_if
   2404 <
   2405     __is_val_expr<_Expr>::value,
   2406     void
   2407 >::type
   2408 indirect_array<_Tp>::operator/=(const _Expr& __v) const
   2409 {
   2410     size_t __n = __1d_.size();
   2411     for (size_t __i = 0; __i < __n; ++__i)
   2412         __vp_[__1d_[__i]] /= __v[__i];
   2413 }
   2414 
   2415 template <class _Tp>
   2416 template <class _Expr>
   2417 inline
   2418 typename enable_if
   2419 <
   2420     __is_val_expr<_Expr>::value,
   2421     void
   2422 >::type
   2423 indirect_array<_Tp>::operator%=(const _Expr& __v) const
   2424 {
   2425     size_t __n = __1d_.size();
   2426     for (size_t __i = 0; __i < __n; ++__i)
   2427         __vp_[__1d_[__i]] %= __v[__i];
   2428 }
   2429 
   2430 template <class _Tp>
   2431 template <class _Expr>
   2432 inline
   2433 typename enable_if
   2434 <
   2435     __is_val_expr<_Expr>::value,
   2436     void
   2437 >::type
   2438 indirect_array<_Tp>::operator+=(const _Expr& __v) const
   2439 {
   2440     size_t __n = __1d_.size();
   2441     for (size_t __i = 0; __i < __n; ++__i)
   2442         __vp_[__1d_[__i]] += __v[__i];
   2443 }
   2444 
   2445 template <class _Tp>
   2446 template <class _Expr>
   2447 inline
   2448 typename enable_if
   2449 <
   2450     __is_val_expr<_Expr>::value,
   2451     void
   2452 >::type
   2453 indirect_array<_Tp>::operator-=(const _Expr& __v) const
   2454 {
   2455     size_t __n = __1d_.size();
   2456     for (size_t __i = 0; __i < __n; ++__i)
   2457         __vp_[__1d_[__i]] -= __v[__i];
   2458 }
   2459 
   2460 template <class _Tp>
   2461 template <class _Expr>
   2462 inline
   2463 typename enable_if
   2464 <
   2465     __is_val_expr<_Expr>::value,
   2466     void
   2467 >::type
   2468 indirect_array<_Tp>::operator^=(const _Expr& __v) const
   2469 {
   2470     size_t __n = __1d_.size();
   2471     for (size_t __i = 0; __i < __n; ++__i)
   2472         __vp_[__1d_[__i]] ^= __v[__i];
   2473 }
   2474 
   2475 template <class _Tp>
   2476 template <class _Expr>
   2477 inline
   2478 typename enable_if
   2479 <
   2480     __is_val_expr<_Expr>::value,
   2481     void
   2482 >::type
   2483 indirect_array<_Tp>::operator&=(const _Expr& __v) const
   2484 {
   2485     size_t __n = __1d_.size();
   2486     for (size_t __i = 0; __i < __n; ++__i)
   2487         __vp_[__1d_[__i]] &= __v[__i];
   2488 }
   2489 
   2490 template <class _Tp>
   2491 template <class _Expr>
   2492 inline
   2493 typename enable_if
   2494 <
   2495     __is_val_expr<_Expr>::value,
   2496     void
   2497 >::type
   2498 indirect_array<_Tp>::operator|=(const _Expr& __v) const
   2499 {
   2500     size_t __n = __1d_.size();
   2501     for (size_t __i = 0; __i < __n; ++__i)
   2502         __vp_[__1d_[__i]] |= __v[__i];
   2503 }
   2504 
   2505 template <class _Tp>
   2506 template <class _Expr>
   2507 inline
   2508 typename enable_if
   2509 <
   2510     __is_val_expr<_Expr>::value,
   2511     void
   2512 >::type
   2513 indirect_array<_Tp>::operator<<=(const _Expr& __v) const
   2514 {
   2515     size_t __n = __1d_.size();
   2516     for (size_t __i = 0; __i < __n; ++__i)
   2517         __vp_[__1d_[__i]] <<= __v[__i];
   2518 }
   2519 
   2520 template <class _Tp>
   2521 template <class _Expr>
   2522 inline
   2523 typename enable_if
   2524 <
   2525     __is_val_expr<_Expr>::value,
   2526     void
   2527 >::type
   2528 indirect_array<_Tp>::operator>>=(const _Expr& __v) const
   2529 {
   2530     size_t __n = __1d_.size();
   2531     for (size_t __i = 0; __i < __n; ++__i)
   2532         __vp_[__1d_[__i]] >>= __v[__i];
   2533 }
   2534 
   2535 template <class _Tp>
   2536 inline
   2537 const indirect_array<_Tp>&
   2538 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
   2539 {
   2540     typedef const size_t* _Ip;
   2541     const value_type* __s = __ia.__vp_;
   2542     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
   2543             __i != __e; ++__i, ++__j)
   2544         __vp_[*__i] = __s[*__j];
   2545     return *this;
   2546 }
   2547 
   2548 template <class _Tp>
   2549 inline
   2550 void
   2551 indirect_array<_Tp>::operator=(const value_type& __x) const
   2552 {
   2553     typedef const size_t* _Ip;
   2554     for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
   2555         __vp_[*__i] = __x;
   2556 }
   2557 
   2558 template <class _ValExpr>
   2559 class __indirect_expr
   2560 {
   2561     typedef typename remove_reference<_ValExpr>::type  _RmExpr;
   2562 public:
   2563     typedef typename _RmExpr::value_type value_type;
   2564     typedef value_type result_type;
   2565 
   2566 private:
   2567     _ValExpr __expr_;
   2568     valarray<size_t> __1d_;
   2569 
   2570     _LIBCPP_INLINE_VISIBILITY
   2571     __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
   2572         : __expr_(__e),
   2573           __1d_(__ia)
   2574           {}
   2575 
   2576 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2577 
   2578     _LIBCPP_INLINE_VISIBILITY
   2579     __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
   2580         : __expr_(__e),
   2581           __1d_(move(__ia))
   2582           {}
   2583 
   2584 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2585 
   2586 public:
   2587     _LIBCPP_INLINE_VISIBILITY
   2588     result_type operator[](size_t __i) const
   2589         {return __expr_[__1d_[__i]];}
   2590 
   2591     _LIBCPP_INLINE_VISIBILITY
   2592     size_t size() const {return __1d_.size();}
   2593 
   2594     template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
   2595 };
   2596 
   2597 template<class _ValExpr>
   2598 class __val_expr
   2599 {
   2600     typedef typename remove_reference<_ValExpr>::type  _RmExpr;
   2601 
   2602     _ValExpr __expr_;
   2603 public:
   2604     typedef typename _RmExpr::value_type value_type;
   2605     typedef typename _RmExpr::result_type result_type;
   2606 
   2607     _LIBCPP_INLINE_VISIBILITY
   2608     explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
   2609 
   2610     _LIBCPP_INLINE_VISIBILITY
   2611     result_type operator[](size_t __i) const
   2612         {return __expr_[__i];}
   2613 
   2614     _LIBCPP_INLINE_VISIBILITY
   2615     __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
   2616         {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
   2617 
   2618     _LIBCPP_INLINE_VISIBILITY
   2619     __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
   2620         {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
   2621 
   2622     _LIBCPP_INLINE_VISIBILITY
   2623     __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
   2624         {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
   2625 
   2626     _LIBCPP_INLINE_VISIBILITY
   2627     __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
   2628         {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
   2629 
   2630     _LIBCPP_INLINE_VISIBILITY
   2631     __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
   2632     operator+() const
   2633     {
   2634         typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
   2635         return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
   2636     }
   2637 
   2638     _LIBCPP_INLINE_VISIBILITY
   2639     __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
   2640     operator-() const
   2641     {
   2642         typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
   2643         return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
   2644     }
   2645 
   2646     _LIBCPP_INLINE_VISIBILITY
   2647     __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
   2648     operator~() const
   2649     {
   2650         typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
   2651         return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
   2652     }
   2653 
   2654     _LIBCPP_INLINE_VISIBILITY
   2655     __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
   2656     operator!() const
   2657     {
   2658         typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
   2659         return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
   2660     }
   2661 
   2662     operator valarray<result_type>() const;
   2663 
   2664     _LIBCPP_INLINE_VISIBILITY
   2665     size_t size() const {return __expr_.size();}
   2666 
   2667     _LIBCPP_INLINE_VISIBILITY
   2668     result_type sum() const
   2669     {
   2670         size_t __n = __expr_.size();
   2671         result_type __r = __n ? __expr_[0] : result_type();
   2672         for (size_t __i = 1; __i < __n; ++__i)
   2673             __r += __expr_[__i];
   2674         return __r;
   2675     }
   2676 
   2677     _LIBCPP_INLINE_VISIBILITY
   2678     result_type min() const
   2679     {
   2680         size_t __n = size();
   2681         result_type __r = __n ? (*this)[0] : result_type();
   2682         for (size_t __i = 1; __i < __n; ++__i)
   2683         {
   2684             result_type __x = __expr_[__i];
   2685             if (__x < __r)
   2686                 __r = __x;
   2687         }
   2688         return __r;
   2689     }
   2690 
   2691     _LIBCPP_INLINE_VISIBILITY
   2692     result_type max() const
   2693     {
   2694         size_t __n = size();
   2695         result_type __r = __n ? (*this)[0] : result_type();
   2696         for (size_t __i = 1; __i < __n; ++__i)
   2697         {
   2698             result_type __x = __expr_[__i];
   2699             if (__r < __x)
   2700                 __r = __x;
   2701         }
   2702         return __r;
   2703     }
   2704 
   2705     _LIBCPP_INLINE_VISIBILITY
   2706     __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
   2707         {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
   2708 
   2709     _LIBCPP_INLINE_VISIBILITY
   2710     __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
   2711         {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
   2712 
   2713     _LIBCPP_INLINE_VISIBILITY
   2714     __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
   2715     apply(value_type __f(value_type)) const
   2716     {
   2717         typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
   2718         typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
   2719         return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
   2720     }
   2721 
   2722     _LIBCPP_INLINE_VISIBILITY
   2723     __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
   2724     apply(value_type __f(const value_type&)) const
   2725     {
   2726         typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
   2727         typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
   2728         return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
   2729     }
   2730 };
   2731 
   2732 template<class _ValExpr>
   2733 __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
   2734 {
   2735     valarray<result_type> __r;
   2736     size_t __n = __expr_.size();
   2737     if (__n)
   2738     {
   2739         __r.__begin_ =
   2740             __r.__end_ =
   2741                 static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
   2742         for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
   2743             ::new (__r.__end_) result_type(__expr_[__i]);
   2744     }
   2745     return __r;
   2746 }
   2747 
   2748 // valarray
   2749 
   2750 template <class _Tp>
   2751 inline
   2752 valarray<_Tp>::valarray(size_t __n)
   2753     : __begin_(0),
   2754       __end_(0)
   2755 {
   2756     resize(__n);
   2757 }
   2758 
   2759 template <class _Tp>
   2760 inline
   2761 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
   2762     : __begin_(0),
   2763       __end_(0)
   2764 {
   2765     resize(__n, __x);
   2766 }
   2767 
   2768 template <class _Tp>
   2769 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
   2770     : __begin_(0),
   2771       __end_(0)
   2772 {
   2773     if (__n)
   2774     {
   2775         __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   2776 #ifndef _LIBCPP_NO_EXCEPTIONS
   2777         try
   2778         {
   2779 #endif  // _LIBCPP_NO_EXCEPTIONS
   2780             for (; __n; ++__end_, ++__p, --__n)
   2781                 ::new (__end_) value_type(*__p);
   2782 #ifndef _LIBCPP_NO_EXCEPTIONS
   2783         }
   2784         catch (...)
   2785         {
   2786             resize(0);
   2787             throw;
   2788         }
   2789 #endif  // _LIBCPP_NO_EXCEPTIONS
   2790     }
   2791 }
   2792 
   2793 template <class _Tp>
   2794 valarray<_Tp>::valarray(const valarray& __v)
   2795     : __begin_(0),
   2796       __end_(0)
   2797 {
   2798     if (__v.size())
   2799     {
   2800         __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
   2801 #ifndef _LIBCPP_NO_EXCEPTIONS
   2802         try
   2803         {
   2804 #endif  // _LIBCPP_NO_EXCEPTIONS
   2805             for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
   2806                 ::new (__end_) value_type(*__p);
   2807 #ifndef _LIBCPP_NO_EXCEPTIONS
   2808         }
   2809         catch (...)
   2810         {
   2811             resize(0);
   2812             throw;
   2813         }
   2814 #endif  // _LIBCPP_NO_EXCEPTIONS
   2815     }
   2816 }
   2817 
   2818 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2819 
   2820 template <class _Tp>
   2821 inline
   2822 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
   2823     : __begin_(__v.__begin_),
   2824       __end_(__v.__end_)
   2825 {
   2826     __v.__begin_ = __v.__end_ = nullptr;
   2827 }
   2828 
   2829 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2830 
   2831 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
   2832 
   2833 template <class _Tp>
   2834 valarray<_Tp>::valarray(initializer_list<value_type> __il)
   2835     : __begin_(0),
   2836       __end_(0)
   2837 {
   2838     size_t __n = __il.size();
   2839     if (__n)
   2840     {
   2841         __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   2842 #ifndef _LIBCPP_NO_EXCEPTIONS
   2843         try
   2844         {
   2845 #endif  // _LIBCPP_NO_EXCEPTIONS
   2846             for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
   2847                 ::new (__end_) value_type(*__p);
   2848 #ifndef _LIBCPP_NO_EXCEPTIONS
   2849         }
   2850         catch (...)
   2851         {
   2852             resize(0);
   2853             throw;
   2854         }
   2855 #endif  // _LIBCPP_NO_EXCEPTIONS
   2856     }
   2857 }
   2858 
   2859 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
   2860 
   2861 template <class _Tp>
   2862 valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
   2863     : __begin_(0),
   2864       __end_(0)
   2865 {
   2866     size_t __n = __sa.__size_;
   2867     if (__n)
   2868     {
   2869         __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   2870 #ifndef _LIBCPP_NO_EXCEPTIONS
   2871         try
   2872         {
   2873 #endif  // _LIBCPP_NO_EXCEPTIONS
   2874             for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
   2875                 ::new (__end_) value_type(*__p);
   2876 #ifndef _LIBCPP_NO_EXCEPTIONS
   2877         }
   2878         catch (...)
   2879         {
   2880             resize(0);
   2881             throw;
   2882         }
   2883 #endif  // _LIBCPP_NO_EXCEPTIONS
   2884     }
   2885 }
   2886 
   2887 template <class _Tp>
   2888 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
   2889     : __begin_(0),
   2890       __end_(0)
   2891 {
   2892     size_t __n = __ga.__1d_.size();
   2893     if (__n)
   2894     {
   2895         __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   2896 #ifndef _LIBCPP_NO_EXCEPTIONS
   2897         try
   2898         {
   2899 #endif  // _LIBCPP_NO_EXCEPTIONS
   2900             typedef const size_t* _Ip;
   2901             const value_type* __s = __ga.__vp_;
   2902             for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
   2903                     __i != __e; ++__i, ++__end_)
   2904                 ::new (__end_) value_type(__s[*__i]);
   2905 #ifndef _LIBCPP_NO_EXCEPTIONS
   2906         }
   2907         catch (...)
   2908         {
   2909             resize(0);
   2910             throw;
   2911         }
   2912 #endif  // _LIBCPP_NO_EXCEPTIONS
   2913     }
   2914 }
   2915 
   2916 template <class _Tp>
   2917 valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
   2918     : __begin_(0),
   2919       __end_(0)
   2920 {
   2921     size_t __n = __ma.__1d_.size();
   2922     if (__n)
   2923     {
   2924         __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   2925 #ifndef _LIBCPP_NO_EXCEPTIONS
   2926         try
   2927         {
   2928 #endif  // _LIBCPP_NO_EXCEPTIONS
   2929             typedef const size_t* _Ip;
   2930             const value_type* __s = __ma.__vp_;
   2931             for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
   2932                     __i != __e; ++__i, ++__end_)
   2933                 ::new (__end_) value_type(__s[*__i]);
   2934 #ifndef _LIBCPP_NO_EXCEPTIONS
   2935         }
   2936         catch (...)
   2937         {
   2938             resize(0);
   2939             throw;
   2940         }
   2941 #endif  // _LIBCPP_NO_EXCEPTIONS
   2942     }
   2943 }
   2944 
   2945 template <class _Tp>
   2946 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
   2947     : __begin_(0),
   2948       __end_(0)
   2949 {
   2950     size_t __n = __ia.__1d_.size();
   2951     if (__n)
   2952     {
   2953         __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   2954 #ifndef _LIBCPP_NO_EXCEPTIONS
   2955         try
   2956         {
   2957 #endif  // _LIBCPP_NO_EXCEPTIONS
   2958             typedef const size_t* _Ip;
   2959             const value_type* __s = __ia.__vp_;
   2960             for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
   2961                     __i != __e; ++__i, ++__end_)
   2962                 ::new (__end_) value_type(__s[*__i]);
   2963 #ifndef _LIBCPP_NO_EXCEPTIONS
   2964         }
   2965         catch (...)
   2966         {
   2967             resize(0);
   2968             throw;
   2969         }
   2970 #endif  // _LIBCPP_NO_EXCEPTIONS
   2971     }
   2972 }
   2973 
   2974 template <class _Tp>
   2975 inline
   2976 valarray<_Tp>::~valarray()
   2977 {
   2978     resize(0);
   2979 }
   2980 
   2981 template <class _Tp>
   2982 valarray<_Tp>&
   2983 valarray<_Tp>::operator=(const valarray& __v)
   2984 {
   2985     if (this != &__v)
   2986     {
   2987         if (size() != __v.size())
   2988             resize(__v.size());
   2989         _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
   2990     }
   2991     return *this;
   2992 }
   2993 
   2994 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   2995 
   2996 template <class _Tp>
   2997 inline
   2998 valarray<_Tp>&
   2999 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
   3000 {
   3001     resize(0);
   3002     __begin_ = __v.__begin_;
   3003     __end_ = __v.__end_;
   3004     __v.__begin_ = nullptr;
   3005     __v.__end_ = nullptr;
   3006     return *this;
   3007 }
   3008 
   3009 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3010 
   3011 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
   3012 
   3013 template <class _Tp>
   3014 inline
   3015 valarray<_Tp>&
   3016 valarray<_Tp>::operator=(initializer_list<value_type> __il)
   3017 {
   3018     if (size() != __il.size())
   3019         resize(__il.size());
   3020     _VSTD::copy(__il.begin(), __il.end(), __begin_);
   3021     return *this;
   3022 }
   3023 
   3024 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
   3025 
   3026 template <class _Tp>
   3027 inline
   3028 valarray<_Tp>&
   3029 valarray<_Tp>::operator=(const value_type& __x)
   3030 {
   3031     _VSTD::fill(__begin_, __end_, __x);
   3032     return *this;
   3033 }
   3034 
   3035 template <class _Tp>
   3036 inline
   3037 valarray<_Tp>&
   3038 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
   3039 {
   3040     value_type* __t = __begin_;
   3041     const value_type* __s = __sa.__vp_;
   3042     for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
   3043         *__t = *__s;
   3044     return *this;
   3045 }
   3046 
   3047 template <class _Tp>
   3048 inline
   3049 valarray<_Tp>&
   3050 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
   3051 {
   3052     typedef const size_t* _Ip;
   3053     value_type* __t = __begin_;
   3054     const value_type* __s = __ga.__vp_;
   3055     for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
   3056                     __i != __e; ++__i, ++__t)
   3057         *__t = __s[*__i];
   3058     return *this;
   3059 }
   3060 
   3061 template <class _Tp>
   3062 inline
   3063 valarray<_Tp>&
   3064 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
   3065 {
   3066     typedef const size_t* _Ip;
   3067     value_type* __t = __begin_;
   3068     const value_type* __s = __ma.__vp_;
   3069     for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
   3070                     __i != __e; ++__i, ++__t)
   3071         *__t = __s[*__i];
   3072     return *this;
   3073 }
   3074 
   3075 template <class _Tp>
   3076 inline
   3077 valarray<_Tp>&
   3078 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
   3079 {
   3080     typedef const size_t* _Ip;
   3081     value_type* __t = __begin_;
   3082     const value_type* __s = __ia.__vp_;
   3083     for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
   3084                     __i != __e; ++__i, ++__t)
   3085         *__t = __s[*__i];
   3086     return *this;
   3087 }
   3088 
   3089 template <class _Tp>
   3090 template <class _ValExpr>
   3091 inline
   3092 valarray<_Tp>&
   3093 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
   3094 {
   3095     size_t __n = __v.size();
   3096     if (size() != __n)
   3097         resize(__n);
   3098     value_type* __t = __begin_;
   3099     for (size_t __i = 0; __i != __n; ++__t, ++__i)
   3100         *__t = result_type(__v[__i]);
   3101     return *this;
   3102 }
   3103 
   3104 template <class _Tp>
   3105 inline
   3106 __val_expr<__slice_expr<const valarray<_Tp>&> >
   3107 valarray<_Tp>::operator[](slice __s) const
   3108 {
   3109     return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
   3110 }
   3111 
   3112 template <class _Tp>
   3113 inline
   3114 slice_array<_Tp>
   3115 valarray<_Tp>::operator[](slice __s)
   3116 {
   3117     return slice_array<value_type>(__s, *this);
   3118 }
   3119 
   3120 template <class _Tp>
   3121 inline
   3122 __val_expr<__indirect_expr<const valarray<_Tp>&> >
   3123 valarray<_Tp>::operator[](const gslice& __gs) const
   3124 {
   3125     return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
   3126 }
   3127 
   3128 template <class _Tp>
   3129 inline
   3130 gslice_array<_Tp>
   3131 valarray<_Tp>::operator[](const gslice& __gs)
   3132 {
   3133     return gslice_array<value_type>(__gs, *this);
   3134 }
   3135 
   3136 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3137 
   3138 template <class _Tp>
   3139 inline
   3140 __val_expr<__indirect_expr<const valarray<_Tp>&> >
   3141 valarray<_Tp>::operator[](gslice&& __gs) const
   3142 {
   3143     return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
   3144 }
   3145 
   3146 template <class _Tp>
   3147 inline
   3148 gslice_array<_Tp>
   3149 valarray<_Tp>::operator[](gslice&& __gs)
   3150 {
   3151     return gslice_array<value_type>(move(__gs), *this);
   3152 }
   3153 
   3154 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3155 
   3156 template <class _Tp>
   3157 inline
   3158 __val_expr<__mask_expr<const valarray<_Tp>&> >
   3159 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
   3160 {
   3161     return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
   3162 }
   3163 
   3164 template <class _Tp>
   3165 inline
   3166 mask_array<_Tp>
   3167 valarray<_Tp>::operator[](const valarray<bool>& __vb)
   3168 {
   3169     return mask_array<value_type>(__vb, *this);
   3170 }
   3171 
   3172 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3173 
   3174 template <class _Tp>
   3175 inline
   3176 __val_expr<__mask_expr<const valarray<_Tp>&> >
   3177 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
   3178 {
   3179     return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
   3180 }
   3181 
   3182 template <class _Tp>
   3183 inline
   3184 mask_array<_Tp>
   3185 valarray<_Tp>::operator[](valarray<bool>&& __vb)
   3186 {
   3187     return mask_array<value_type>(move(__vb), *this);
   3188 }
   3189 
   3190 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3191 
   3192 template <class _Tp>
   3193 inline
   3194 __val_expr<__indirect_expr<const valarray<_Tp>&> >
   3195 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
   3196 {
   3197     return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
   3198 }
   3199 
   3200 template <class _Tp>
   3201 inline
   3202 indirect_array<_Tp>
   3203 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
   3204 {
   3205     return indirect_array<value_type>(__vs, *this);
   3206 }
   3207 
   3208 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3209 
   3210 template <class _Tp>
   3211 inline
   3212 __val_expr<__indirect_expr<const valarray<_Tp>&> >
   3213 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
   3214 {
   3215     return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
   3216 }
   3217 
   3218 template <class _Tp>
   3219 inline
   3220 indirect_array<_Tp>
   3221 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
   3222 {
   3223     return indirect_array<value_type>(move(__vs), *this);
   3224 }
   3225 
   3226 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
   3227 
   3228 template <class _Tp>
   3229 valarray<_Tp>
   3230 valarray<_Tp>::operator+() const
   3231 {
   3232     valarray<value_type> __r;
   3233     size_t __n = size();
   3234     if (__n)
   3235     {
   3236         __r.__begin_ =
   3237             __r.__end_ =
   3238                 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   3239         for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
   3240             ::new (__r.__end_) value_type(+*__p);
   3241     }
   3242     return __r;
   3243 }
   3244 
   3245 template <class _Tp>
   3246 valarray<_Tp>
   3247 valarray<_Tp>::operator-() const
   3248 {
   3249     valarray<value_type> __r;
   3250     size_t __n = size();
   3251     if (__n)
   3252     {
   3253         __r.__begin_ =
   3254             __r.__end_ =
   3255                 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   3256         for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
   3257             ::new (__r.__end_) value_type(-*__p);
   3258     }
   3259     return __r;
   3260 }
   3261 
   3262 template <class _Tp>
   3263 valarray<_Tp>
   3264 valarray<_Tp>::operator~() const
   3265 {
   3266     valarray<value_type> __r;
   3267     size_t __n = size();
   3268     if (__n)
   3269     {
   3270         __r.__begin_ =
   3271             __r.__end_ =
   3272                 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   3273         for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
   3274             ::new (__r.__end_) value_type(~*__p);
   3275     }
   3276     return __r;
   3277 }
   3278 
   3279 template <class _Tp>
   3280 valarray<bool>
   3281 valarray<_Tp>::operator!() const
   3282 {
   3283     valarray<bool> __r;
   3284     size_t __n = size();
   3285     if (__n)
   3286     {
   3287         __r.__begin_ =
   3288             __r.__end_ =
   3289                 static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
   3290         for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
   3291             ::new (__r.__end_) bool(!*__p);
   3292     }
   3293     return __r;
   3294 }
   3295 
   3296 template <class _Tp>
   3297 inline
   3298 valarray<_Tp>&
   3299 valarray<_Tp>::operator*=(const value_type& __x)
   3300 {
   3301     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3302         *__p *= __x;
   3303     return *this;
   3304 }
   3305 
   3306 template <class _Tp>
   3307 inline
   3308 valarray<_Tp>&
   3309 valarray<_Tp>::operator/=(const value_type& __x)
   3310 {
   3311     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3312         *__p /= __x;
   3313     return *this;
   3314 }
   3315 
   3316 template <class _Tp>
   3317 inline
   3318 valarray<_Tp>&
   3319 valarray<_Tp>::operator%=(const value_type& __x)
   3320 {
   3321     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3322         *__p %= __x;
   3323     return *this;
   3324 }
   3325 
   3326 template <class _Tp>
   3327 inline
   3328 valarray<_Tp>&
   3329 valarray<_Tp>::operator+=(const value_type& __x)
   3330 {
   3331     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3332         *__p += __x;
   3333     return *this;
   3334 }
   3335 
   3336 template <class _Tp>
   3337 inline
   3338 valarray<_Tp>&
   3339 valarray<_Tp>::operator-=(const value_type& __x)
   3340 {
   3341     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3342         *__p -= __x;
   3343     return *this;
   3344 }
   3345 
   3346 template <class _Tp>
   3347 inline
   3348 valarray<_Tp>&
   3349 valarray<_Tp>::operator^=(const value_type& __x)
   3350 {
   3351     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3352         *__p ^= __x;
   3353     return *this;
   3354 }
   3355 
   3356 template <class _Tp>
   3357 inline
   3358 valarray<_Tp>&
   3359 valarray<_Tp>::operator&=(const value_type& __x)
   3360 {
   3361     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3362         *__p &= __x;
   3363     return *this;
   3364 }
   3365 
   3366 template <class _Tp>
   3367 inline
   3368 valarray<_Tp>&
   3369 valarray<_Tp>::operator|=(const value_type& __x)
   3370 {
   3371     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3372         *__p |= __x;
   3373     return *this;
   3374 }
   3375 
   3376 template <class _Tp>
   3377 inline
   3378 valarray<_Tp>&
   3379 valarray<_Tp>::operator<<=(const value_type& __x)
   3380 {
   3381     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3382         *__p <<= __x;
   3383     return *this;
   3384 }
   3385 
   3386 template <class _Tp>
   3387 inline
   3388 valarray<_Tp>&
   3389 valarray<_Tp>::operator>>=(const value_type& __x)
   3390 {
   3391     for (value_type* __p = __begin_; __p != __end_; ++__p)
   3392         *__p >>= __x;
   3393     return *this;
   3394 }
   3395 
   3396 template <class _Tp>
   3397 template <class _Expr>
   3398 inline
   3399 typename enable_if
   3400 <
   3401     __is_val_expr<_Expr>::value,
   3402     valarray<_Tp>&
   3403 >::type
   3404 valarray<_Tp>::operator*=(const _Expr& __v)
   3405 {
   3406     size_t __i = 0;
   3407     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3408         *__t *= __v[__i];
   3409     return *this;
   3410 }
   3411 
   3412 template <class _Tp>
   3413 template <class _Expr>
   3414 inline
   3415 typename enable_if
   3416 <
   3417     __is_val_expr<_Expr>::value,
   3418     valarray<_Tp>&
   3419 >::type
   3420 valarray<_Tp>::operator/=(const _Expr& __v)
   3421 {
   3422     size_t __i = 0;
   3423     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3424         *__t /= __v[__i];
   3425     return *this;
   3426 }
   3427 
   3428 template <class _Tp>
   3429 template <class _Expr>
   3430 inline
   3431 typename enable_if
   3432 <
   3433     __is_val_expr<_Expr>::value,
   3434     valarray<_Tp>&
   3435 >::type
   3436 valarray<_Tp>::operator%=(const _Expr& __v)
   3437 {
   3438     size_t __i = 0;
   3439     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3440         *__t %= __v[__i];
   3441     return *this;
   3442 }
   3443 
   3444 template <class _Tp>
   3445 template <class _Expr>
   3446 inline
   3447 typename enable_if
   3448 <
   3449     __is_val_expr<_Expr>::value,
   3450     valarray<_Tp>&
   3451 >::type
   3452 valarray<_Tp>::operator+=(const _Expr& __v)
   3453 {
   3454     size_t __i = 0;
   3455     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3456         *__t += __v[__i];
   3457     return *this;
   3458 }
   3459 
   3460 template <class _Tp>
   3461 template <class _Expr>
   3462 inline
   3463 typename enable_if
   3464 <
   3465     __is_val_expr<_Expr>::value,
   3466     valarray<_Tp>&
   3467 >::type
   3468 valarray<_Tp>::operator-=(const _Expr& __v)
   3469 {
   3470     size_t __i = 0;
   3471     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3472         *__t -= __v[__i];
   3473     return *this;
   3474 }
   3475 
   3476 template <class _Tp>
   3477 template <class _Expr>
   3478 inline
   3479 typename enable_if
   3480 <
   3481     __is_val_expr<_Expr>::value,
   3482     valarray<_Tp>&
   3483 >::type
   3484 valarray<_Tp>::operator^=(const _Expr& __v)
   3485 {
   3486     size_t __i = 0;
   3487     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3488         *__t ^= __v[__i];
   3489     return *this;
   3490 }
   3491 
   3492 template <class _Tp>
   3493 template <class _Expr>
   3494 inline
   3495 typename enable_if
   3496 <
   3497     __is_val_expr<_Expr>::value,
   3498     valarray<_Tp>&
   3499 >::type
   3500 valarray<_Tp>::operator|=(const _Expr& __v)
   3501 {
   3502     size_t __i = 0;
   3503     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3504         *__t |= __v[__i];
   3505     return *this;
   3506 }
   3507 
   3508 template <class _Tp>
   3509 template <class _Expr>
   3510 inline
   3511 typename enable_if
   3512 <
   3513     __is_val_expr<_Expr>::value,
   3514     valarray<_Tp>&
   3515 >::type
   3516 valarray<_Tp>::operator&=(const _Expr& __v)
   3517 {
   3518     size_t __i = 0;
   3519     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3520         *__t &= __v[__i];
   3521     return *this;
   3522 }
   3523 
   3524 template <class _Tp>
   3525 template <class _Expr>
   3526 inline
   3527 typename enable_if
   3528 <
   3529     __is_val_expr<_Expr>::value,
   3530     valarray<_Tp>&
   3531 >::type
   3532 valarray<_Tp>::operator<<=(const _Expr& __v)
   3533 {
   3534     size_t __i = 0;
   3535     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3536         *__t <<= __v[__i];
   3537     return *this;
   3538 }
   3539 
   3540 template <class _Tp>
   3541 template <class _Expr>
   3542 inline
   3543 typename enable_if
   3544 <
   3545     __is_val_expr<_Expr>::value,
   3546     valarray<_Tp>&
   3547 >::type
   3548 valarray<_Tp>::operator>>=(const _Expr& __v)
   3549 {
   3550     size_t __i = 0;
   3551     for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
   3552         *__t >>= __v[__i];
   3553     return *this;
   3554 }
   3555 
   3556 template <class _Tp>
   3557 inline
   3558 void
   3559 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
   3560 {
   3561     _VSTD::swap(__begin_, __v.__begin_);
   3562     _VSTD::swap(__end_, __v.__end_);
   3563 }
   3564 
   3565 template <class _Tp>
   3566 inline
   3567 _Tp
   3568 valarray<_Tp>::sum() const
   3569 {
   3570     if (__begin_ == __end_)
   3571         return value_type();
   3572     const value_type* __p = __begin_;
   3573     _Tp __r = *__p;
   3574     for (++__p; __p != __end_; ++__p)
   3575         __r += *__p;
   3576     return __r;
   3577 }
   3578 
   3579 template <class _Tp>
   3580 inline
   3581 _Tp
   3582 valarray<_Tp>::min() const
   3583 {
   3584     if (__begin_ == __end_)
   3585         return value_type();
   3586     return *_VSTD::min_element(__begin_, __end_);
   3587 }
   3588 
   3589 template <class _Tp>
   3590 inline
   3591 _Tp
   3592 valarray<_Tp>::max() const
   3593 {
   3594     if (__begin_ == __end_)
   3595         return value_type();
   3596     return *_VSTD::max_element(__begin_, __end_);
   3597 }
   3598 
   3599 template <class _Tp>
   3600 valarray<_Tp>
   3601 valarray<_Tp>::shift(int __i) const
   3602 {
   3603     valarray<value_type> __r;
   3604     size_t __n = size();
   3605     if (__n)
   3606     {
   3607         __r.__begin_ =
   3608             __r.__end_ =
   3609                 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   3610         const value_type* __sb;
   3611         value_type* __tb;
   3612         value_type* __te;
   3613         if (__i >= 0)
   3614         {
   3615             __i = _VSTD::min(__i, static_cast<int>(__n));
   3616             __sb = __begin_ + __i;
   3617             __tb = __r.__begin_;
   3618             __te = __r.__begin_ + (__n - __i);
   3619         }
   3620         else
   3621         {
   3622             __i = _VSTD::min(-__i, static_cast<int>(__n));
   3623             __sb = __begin_;
   3624             __tb = __r.__begin_ + __i;
   3625             __te = __r.__begin_ + __n;
   3626         }
   3627         for (; __r.__end_ != __tb; ++__r.__end_)
   3628             ::new (__r.__end_) value_type();
   3629         for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
   3630             ::new (__r.__end_) value_type(*__sb);
   3631         for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
   3632             ::new (__r.__end_) value_type();
   3633     }
   3634     return __r;
   3635 }
   3636 
   3637 template <class _Tp>
   3638 valarray<_Tp>
   3639 valarray<_Tp>::cshift(int __i) const
   3640 {
   3641     valarray<value_type> __r;
   3642     size_t __n = size();
   3643     if (__n)
   3644     {
   3645         __r.__begin_ =
   3646             __r.__end_ =
   3647                 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   3648         __i %= static_cast<int>(__n);
   3649         const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
   3650         for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
   3651             ::new (__r.__end_) value_type(*__s);
   3652         for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
   3653             ::new (__r.__end_) value_type(*__s);
   3654     }
   3655     return __r;
   3656 }
   3657 
   3658 template <class _Tp>
   3659 valarray<_Tp>
   3660 valarray<_Tp>::apply(value_type __f(value_type)) const
   3661 {
   3662     valarray<value_type> __r;
   3663     size_t __n = size();
   3664     if (__n)
   3665     {
   3666         __r.__begin_ =
   3667             __r.__end_ =
   3668                 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   3669         for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
   3670             ::new (__r.__end_) value_type(__f(*__p));
   3671     }
   3672     return __r;
   3673 }
   3674 
   3675 template <class _Tp>
   3676 valarray<_Tp>
   3677 valarray<_Tp>::apply(value_type __f(const value_type&)) const
   3678 {
   3679     valarray<value_type> __r;
   3680     size_t __n = size();
   3681     if (__n)
   3682     {
   3683         __r.__begin_ =
   3684             __r.__end_ =
   3685                 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   3686         for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
   3687             ::new (__r.__end_) value_type(__f(*__p));
   3688     }
   3689     return __r;
   3690 }
   3691 
   3692 template <class _Tp>
   3693 void
   3694 valarray<_Tp>::resize(size_t __n, value_type __x)
   3695 {
   3696     if (__begin_ != nullptr)
   3697     {
   3698         while (__end_ != __begin_)
   3699             (--__end_)->~value_type();
   3700         _VSTD::__deallocate(__begin_);
   3701         __begin_ = __end_ = nullptr;
   3702     }
   3703     if (__n)
   3704     {
   3705         __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
   3706 #ifndef _LIBCPP_NO_EXCEPTIONS
   3707         try
   3708         {
   3709 #endif  // _LIBCPP_NO_EXCEPTIONS
   3710             for (; __n; --__n, ++__end_)
   3711                 ::new (__end_) value_type(__x);
   3712 #ifndef _LIBCPP_NO_EXCEPTIONS
   3713         }
   3714         catch (...)
   3715         {
   3716             resize(0);
   3717             throw;
   3718         }
   3719 #endif  // _LIBCPP_NO_EXCEPTIONS
   3720     }
   3721 }
   3722 
   3723 template<class _Tp>
   3724 inline _LIBCPP_INLINE_VISIBILITY
   3725 void
   3726 swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
   3727 {
   3728     __x.swap(__y);
   3729 }
   3730 
   3731 template<class _Expr1, class _Expr2>
   3732 inline _LIBCPP_INLINE_VISIBILITY
   3733 typename enable_if
   3734 <
   3735     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   3736     __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
   3737 >::type
   3738 operator*(const _Expr1& __x, const _Expr2& __y)
   3739 {
   3740     typedef typename _Expr1::value_type value_type;
   3741     typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
   3742     return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
   3743 }
   3744 
   3745 template<class _Expr>
   3746 inline _LIBCPP_INLINE_VISIBILITY
   3747 typename enable_if
   3748 <
   3749     __is_val_expr<_Expr>::value,
   3750     __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
   3751                _Expr, __scalar_expr<typename _Expr::value_type> > >
   3752 >::type
   3753 operator*(const _Expr& __x, const typename _Expr::value_type& __y)
   3754 {
   3755     typedef typename _Expr::value_type value_type;
   3756     typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   3757     return __val_expr<_Op>(_Op(multiplies<value_type>(),
   3758                            __x, __scalar_expr<value_type>(__y, __x.size())));
   3759 }
   3760 
   3761 template<class _Expr>
   3762 inline _LIBCPP_INLINE_VISIBILITY
   3763 typename enable_if
   3764 <
   3765     __is_val_expr<_Expr>::value,
   3766     __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
   3767                __scalar_expr<typename _Expr::value_type>, _Expr> >
   3768 >::type
   3769 operator*(const typename _Expr::value_type& __x, const _Expr& __y)
   3770 {
   3771     typedef typename _Expr::value_type value_type;
   3772     typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   3773     return __val_expr<_Op>(_Op(multiplies<value_type>(),
   3774                            __scalar_expr<value_type>(__x, __y.size()), __y));
   3775 }
   3776 
   3777 template<class _Expr1, class _Expr2>
   3778 inline _LIBCPP_INLINE_VISIBILITY
   3779 typename enable_if
   3780 <
   3781     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   3782     __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
   3783 >::type
   3784 operator/(const _Expr1& __x, const _Expr2& __y)
   3785 {
   3786     typedef typename _Expr1::value_type value_type;
   3787     typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
   3788     return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
   3789 }
   3790 
   3791 template<class _Expr>
   3792 inline _LIBCPP_INLINE_VISIBILITY
   3793 typename enable_if
   3794 <
   3795     __is_val_expr<_Expr>::value,
   3796     __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
   3797                _Expr, __scalar_expr<typename _Expr::value_type> > >
   3798 >::type
   3799 operator/(const _Expr& __x, const typename _Expr::value_type& __y)
   3800 {
   3801     typedef typename _Expr::value_type value_type;
   3802     typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   3803     return __val_expr<_Op>(_Op(divides<value_type>(),
   3804                            __x, __scalar_expr<value_type>(__y, __x.size())));
   3805 }
   3806 
   3807 template<class _Expr>
   3808 inline _LIBCPP_INLINE_VISIBILITY
   3809 typename enable_if
   3810 <
   3811     __is_val_expr<_Expr>::value,
   3812     __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
   3813                __scalar_expr<typename _Expr::value_type>, _Expr> >
   3814 >::type
   3815 operator/(const typename _Expr::value_type& __x, const _Expr& __y)
   3816 {
   3817     typedef typename _Expr::value_type value_type;
   3818     typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   3819     return __val_expr<_Op>(_Op(divides<value_type>(),
   3820                            __scalar_expr<value_type>(__x, __y.size()), __y));
   3821 }
   3822 
   3823 template<class _Expr1, class _Expr2>
   3824 inline _LIBCPP_INLINE_VISIBILITY
   3825 typename enable_if
   3826 <
   3827     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   3828     __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
   3829 >::type
   3830 operator%(const _Expr1& __x, const _Expr2& __y)
   3831 {
   3832     typedef typename _Expr1::value_type value_type;
   3833     typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
   3834     return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
   3835 }
   3836 
   3837 template<class _Expr>
   3838 inline _LIBCPP_INLINE_VISIBILITY
   3839 typename enable_if
   3840 <
   3841     __is_val_expr<_Expr>::value,
   3842     __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
   3843                _Expr, __scalar_expr<typename _Expr::value_type> > >
   3844 >::type
   3845 operator%(const _Expr& __x, const typename _Expr::value_type& __y)
   3846 {
   3847     typedef typename _Expr::value_type value_type;
   3848     typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   3849     return __val_expr<_Op>(_Op(modulus<value_type>(),
   3850                            __x, __scalar_expr<value_type>(__y, __x.size())));
   3851 }
   3852 
   3853 template<class _Expr>
   3854 inline _LIBCPP_INLINE_VISIBILITY
   3855 typename enable_if
   3856 <
   3857     __is_val_expr<_Expr>::value,
   3858     __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
   3859                __scalar_expr<typename _Expr::value_type>, _Expr> >
   3860 >::type
   3861 operator%(const typename _Expr::value_type& __x, const _Expr& __y)
   3862 {
   3863     typedef typename _Expr::value_type value_type;
   3864     typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   3865     return __val_expr<_Op>(_Op(modulus<value_type>(),
   3866                            __scalar_expr<value_type>(__x, __y.size()), __y));
   3867 }
   3868 
   3869 template<class _Expr1, class _Expr2>
   3870 inline _LIBCPP_INLINE_VISIBILITY
   3871 typename enable_if
   3872 <
   3873     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   3874     __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
   3875 >::type
   3876 operator+(const _Expr1& __x, const _Expr2& __y)
   3877 {
   3878     typedef typename _Expr1::value_type value_type;
   3879     typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
   3880     return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
   3881 }
   3882 
   3883 template<class _Expr>
   3884 inline _LIBCPP_INLINE_VISIBILITY
   3885 typename enable_if
   3886 <
   3887     __is_val_expr<_Expr>::value,
   3888     __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
   3889                _Expr, __scalar_expr<typename _Expr::value_type> > >
   3890 >::type
   3891 operator+(const _Expr& __x, const typename _Expr::value_type& __y)
   3892 {
   3893     typedef typename _Expr::value_type value_type;
   3894     typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   3895     return __val_expr<_Op>(_Op(plus<value_type>(),
   3896                            __x, __scalar_expr<value_type>(__y, __x.size())));
   3897 }
   3898 
   3899 template<class _Expr>
   3900 inline _LIBCPP_INLINE_VISIBILITY
   3901 typename enable_if
   3902 <
   3903     __is_val_expr<_Expr>::value,
   3904     __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
   3905                __scalar_expr<typename _Expr::value_type>, _Expr> >
   3906 >::type
   3907 operator+(const typename _Expr::value_type& __x, const _Expr& __y)
   3908 {
   3909     typedef typename _Expr::value_type value_type;
   3910     typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   3911     return __val_expr<_Op>(_Op(plus<value_type>(),
   3912                            __scalar_expr<value_type>(__x, __y.size()), __y));
   3913 }
   3914 
   3915 template<class _Expr1, class _Expr2>
   3916 inline _LIBCPP_INLINE_VISIBILITY
   3917 typename enable_if
   3918 <
   3919     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   3920     __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
   3921 >::type
   3922 operator-(const _Expr1& __x, const _Expr2& __y)
   3923 {
   3924     typedef typename _Expr1::value_type value_type;
   3925     typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
   3926     return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
   3927 }
   3928 
   3929 template<class _Expr>
   3930 inline _LIBCPP_INLINE_VISIBILITY
   3931 typename enable_if
   3932 <
   3933     __is_val_expr<_Expr>::value,
   3934     __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
   3935                _Expr, __scalar_expr<typename _Expr::value_type> > >
   3936 >::type
   3937 operator-(const _Expr& __x, const typename _Expr::value_type& __y)
   3938 {
   3939     typedef typename _Expr::value_type value_type;
   3940     typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   3941     return __val_expr<_Op>(_Op(minus<value_type>(),
   3942                            __x, __scalar_expr<value_type>(__y, __x.size())));
   3943 }
   3944 
   3945 template<class _Expr>
   3946 inline _LIBCPP_INLINE_VISIBILITY
   3947 typename enable_if
   3948 <
   3949     __is_val_expr<_Expr>::value,
   3950     __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
   3951                __scalar_expr<typename _Expr::value_type>, _Expr> >
   3952 >::type
   3953 operator-(const typename _Expr::value_type& __x, const _Expr& __y)
   3954 {
   3955     typedef typename _Expr::value_type value_type;
   3956     typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   3957     return __val_expr<_Op>(_Op(minus<value_type>(),
   3958                            __scalar_expr<value_type>(__x, __y.size()), __y));
   3959 }
   3960 
   3961 template<class _Expr1, class _Expr2>
   3962 inline _LIBCPP_INLINE_VISIBILITY
   3963 typename enable_if
   3964 <
   3965     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   3966     __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
   3967 >::type
   3968 operator^(const _Expr1& __x, const _Expr2& __y)
   3969 {
   3970     typedef typename _Expr1::value_type value_type;
   3971     typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
   3972     return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
   3973 }
   3974 
   3975 template<class _Expr>
   3976 inline _LIBCPP_INLINE_VISIBILITY
   3977 typename enable_if
   3978 <
   3979     __is_val_expr<_Expr>::value,
   3980     __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
   3981                _Expr, __scalar_expr<typename _Expr::value_type> > >
   3982 >::type
   3983 operator^(const _Expr& __x, const typename _Expr::value_type& __y)
   3984 {
   3985     typedef typename _Expr::value_type value_type;
   3986     typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   3987     return __val_expr<_Op>(_Op(bit_xor<value_type>(),
   3988                            __x, __scalar_expr<value_type>(__y, __x.size())));
   3989 }
   3990 
   3991 template<class _Expr>
   3992 inline _LIBCPP_INLINE_VISIBILITY
   3993 typename enable_if
   3994 <
   3995     __is_val_expr<_Expr>::value,
   3996     __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
   3997                __scalar_expr<typename _Expr::value_type>, _Expr> >
   3998 >::type
   3999 operator^(const typename _Expr::value_type& __x, const _Expr& __y)
   4000 {
   4001     typedef typename _Expr::value_type value_type;
   4002     typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4003     return __val_expr<_Op>(_Op(bit_xor<value_type>(),
   4004                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4005 }
   4006 
   4007 template<class _Expr1, class _Expr2>
   4008 inline _LIBCPP_INLINE_VISIBILITY
   4009 typename enable_if
   4010 <
   4011     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4012     __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4013 >::type
   4014 operator&(const _Expr1& __x, const _Expr2& __y)
   4015 {
   4016     typedef typename _Expr1::value_type value_type;
   4017     typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
   4018     return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
   4019 }
   4020 
   4021 template<class _Expr>
   4022 inline _LIBCPP_INLINE_VISIBILITY
   4023 typename enable_if
   4024 <
   4025     __is_val_expr<_Expr>::value,
   4026     __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
   4027                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4028 >::type
   4029 operator&(const _Expr& __x, const typename _Expr::value_type& __y)
   4030 {
   4031     typedef typename _Expr::value_type value_type;
   4032     typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4033     return __val_expr<_Op>(_Op(bit_and<value_type>(),
   4034                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4035 }
   4036 
   4037 template<class _Expr>
   4038 inline _LIBCPP_INLINE_VISIBILITY
   4039 typename enable_if
   4040 <
   4041     __is_val_expr<_Expr>::value,
   4042     __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
   4043                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4044 >::type
   4045 operator&(const typename _Expr::value_type& __x, const _Expr& __y)
   4046 {
   4047     typedef typename _Expr::value_type value_type;
   4048     typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4049     return __val_expr<_Op>(_Op(bit_and<value_type>(),
   4050                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4051 }
   4052 
   4053 template<class _Expr1, class _Expr2>
   4054 inline _LIBCPP_INLINE_VISIBILITY
   4055 typename enable_if
   4056 <
   4057     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4058     __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4059 >::type
   4060 operator|(const _Expr1& __x, const _Expr2& __y)
   4061 {
   4062     typedef typename _Expr1::value_type value_type;
   4063     typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
   4064     return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
   4065 }
   4066 
   4067 template<class _Expr>
   4068 inline _LIBCPP_INLINE_VISIBILITY
   4069 typename enable_if
   4070 <
   4071     __is_val_expr<_Expr>::value,
   4072     __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
   4073                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4074 >::type
   4075 operator|(const _Expr& __x, const typename _Expr::value_type& __y)
   4076 {
   4077     typedef typename _Expr::value_type value_type;
   4078     typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4079     return __val_expr<_Op>(_Op(bit_or<value_type>(),
   4080                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4081 }
   4082 
   4083 template<class _Expr>
   4084 inline _LIBCPP_INLINE_VISIBILITY
   4085 typename enable_if
   4086 <
   4087     __is_val_expr<_Expr>::value,
   4088     __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
   4089                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4090 >::type
   4091 operator|(const typename _Expr::value_type& __x, const _Expr& __y)
   4092 {
   4093     typedef typename _Expr::value_type value_type;
   4094     typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4095     return __val_expr<_Op>(_Op(bit_or<value_type>(),
   4096                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4097 }
   4098 
   4099 template<class _Expr1, class _Expr2>
   4100 inline _LIBCPP_INLINE_VISIBILITY
   4101 typename enable_if
   4102 <
   4103     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4104     __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4105 >::type
   4106 operator<<(const _Expr1& __x, const _Expr2& __y)
   4107 {
   4108     typedef typename _Expr1::value_type value_type;
   4109     typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
   4110     return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
   4111 }
   4112 
   4113 template<class _Expr>
   4114 inline _LIBCPP_INLINE_VISIBILITY
   4115 typename enable_if
   4116 <
   4117     __is_val_expr<_Expr>::value,
   4118     __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
   4119                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4120 >::type
   4121 operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
   4122 {
   4123     typedef typename _Expr::value_type value_type;
   4124     typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4125     return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
   4126                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4127 }
   4128 
   4129 template<class _Expr>
   4130 inline _LIBCPP_INLINE_VISIBILITY
   4131 typename enable_if
   4132 <
   4133     __is_val_expr<_Expr>::value,
   4134     __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
   4135                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4136 >::type
   4137 operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
   4138 {
   4139     typedef typename _Expr::value_type value_type;
   4140     typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4141     return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
   4142                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4143 }
   4144 
   4145 template<class _Expr1, class _Expr2>
   4146 inline _LIBCPP_INLINE_VISIBILITY
   4147 typename enable_if
   4148 <
   4149     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4150     __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4151 >::type
   4152 operator>>(const _Expr1& __x, const _Expr2& __y)
   4153 {
   4154     typedef typename _Expr1::value_type value_type;
   4155     typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
   4156     return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
   4157 }
   4158 
   4159 template<class _Expr>
   4160 inline _LIBCPP_INLINE_VISIBILITY
   4161 typename enable_if
   4162 <
   4163     __is_val_expr<_Expr>::value,
   4164     __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
   4165                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4166 >::type
   4167 operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
   4168 {
   4169     typedef typename _Expr::value_type value_type;
   4170     typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4171     return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
   4172                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4173 }
   4174 
   4175 template<class _Expr>
   4176 inline _LIBCPP_INLINE_VISIBILITY
   4177 typename enable_if
   4178 <
   4179     __is_val_expr<_Expr>::value,
   4180     __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
   4181                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4182 >::type
   4183 operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
   4184 {
   4185     typedef typename _Expr::value_type value_type;
   4186     typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4187     return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
   4188                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4189 }
   4190 
   4191 template<class _Expr1, class _Expr2>
   4192 inline _LIBCPP_INLINE_VISIBILITY
   4193 typename enable_if
   4194 <
   4195     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4196     __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4197 >::type
   4198 operator&&(const _Expr1& __x, const _Expr2& __y)
   4199 {
   4200     typedef typename _Expr1::value_type value_type;
   4201     typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
   4202     return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
   4203 }
   4204 
   4205 template<class _Expr>
   4206 inline _LIBCPP_INLINE_VISIBILITY
   4207 typename enable_if
   4208 <
   4209     __is_val_expr<_Expr>::value,
   4210     __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
   4211                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4212 >::type
   4213 operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
   4214 {
   4215     typedef typename _Expr::value_type value_type;
   4216     typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4217     return __val_expr<_Op>(_Op(logical_and<value_type>(),
   4218                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4219 }
   4220 
   4221 template<class _Expr>
   4222 inline _LIBCPP_INLINE_VISIBILITY
   4223 typename enable_if
   4224 <
   4225     __is_val_expr<_Expr>::value,
   4226     __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
   4227                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4228 >::type
   4229 operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
   4230 {
   4231     typedef typename _Expr::value_type value_type;
   4232     typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4233     return __val_expr<_Op>(_Op(logical_and<value_type>(),
   4234                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4235 }
   4236 
   4237 template<class _Expr1, class _Expr2>
   4238 inline _LIBCPP_INLINE_VISIBILITY
   4239 typename enable_if
   4240 <
   4241     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4242     __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4243 >::type
   4244 operator||(const _Expr1& __x, const _Expr2& __y)
   4245 {
   4246     typedef typename _Expr1::value_type value_type;
   4247     typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
   4248     return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
   4249 }
   4250 
   4251 template<class _Expr>
   4252 inline _LIBCPP_INLINE_VISIBILITY
   4253 typename enable_if
   4254 <
   4255     __is_val_expr<_Expr>::value,
   4256     __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
   4257                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4258 >::type
   4259 operator||(const _Expr& __x, const typename _Expr::value_type& __y)
   4260 {
   4261     typedef typename _Expr::value_type value_type;
   4262     typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4263     return __val_expr<_Op>(_Op(logical_or<value_type>(),
   4264                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4265 }
   4266 
   4267 template<class _Expr>
   4268 inline _LIBCPP_INLINE_VISIBILITY
   4269 typename enable_if
   4270 <
   4271     __is_val_expr<_Expr>::value,
   4272     __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
   4273                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4274 >::type
   4275 operator||(const typename _Expr::value_type& __x, const _Expr& __y)
   4276 {
   4277     typedef typename _Expr::value_type value_type;
   4278     typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4279     return __val_expr<_Op>(_Op(logical_or<value_type>(),
   4280                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4281 }
   4282 
   4283 template<class _Expr1, class _Expr2>
   4284 inline _LIBCPP_INLINE_VISIBILITY
   4285 typename enable_if
   4286 <
   4287     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4288     __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4289 >::type
   4290 operator==(const _Expr1& __x, const _Expr2& __y)
   4291 {
   4292     typedef typename _Expr1::value_type value_type;
   4293     typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
   4294     return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
   4295 }
   4296 
   4297 template<class _Expr>
   4298 inline _LIBCPP_INLINE_VISIBILITY
   4299 typename enable_if
   4300 <
   4301     __is_val_expr<_Expr>::value,
   4302     __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
   4303                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4304 >::type
   4305 operator==(const _Expr& __x, const typename _Expr::value_type& __y)
   4306 {
   4307     typedef typename _Expr::value_type value_type;
   4308     typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4309     return __val_expr<_Op>(_Op(equal_to<value_type>(),
   4310                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4311 }
   4312 
   4313 template<class _Expr>
   4314 inline _LIBCPP_INLINE_VISIBILITY
   4315 typename enable_if
   4316 <
   4317     __is_val_expr<_Expr>::value,
   4318     __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
   4319                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4320 >::type
   4321 operator==(const typename _Expr::value_type& __x, const _Expr& __y)
   4322 {
   4323     typedef typename _Expr::value_type value_type;
   4324     typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4325     return __val_expr<_Op>(_Op(equal_to<value_type>(),
   4326                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4327 }
   4328 
   4329 template<class _Expr1, class _Expr2>
   4330 inline _LIBCPP_INLINE_VISIBILITY
   4331 typename enable_if
   4332 <
   4333     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4334     __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4335 >::type
   4336 operator!=(const _Expr1& __x, const _Expr2& __y)
   4337 {
   4338     typedef typename _Expr1::value_type value_type;
   4339     typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
   4340     return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
   4341 }
   4342 
   4343 template<class _Expr>
   4344 inline _LIBCPP_INLINE_VISIBILITY
   4345 typename enable_if
   4346 <
   4347     __is_val_expr<_Expr>::value,
   4348     __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
   4349                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4350 >::type
   4351 operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
   4352 {
   4353     typedef typename _Expr::value_type value_type;
   4354     typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4355     return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
   4356                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4357 }
   4358 
   4359 template<class _Expr>
   4360 inline _LIBCPP_INLINE_VISIBILITY
   4361 typename enable_if
   4362 <
   4363     __is_val_expr<_Expr>::value,
   4364     __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
   4365                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4366 >::type
   4367 operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
   4368 {
   4369     typedef typename _Expr::value_type value_type;
   4370     typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4371     return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
   4372                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4373 }
   4374 
   4375 template<class _Expr1, class _Expr2>
   4376 inline _LIBCPP_INLINE_VISIBILITY
   4377 typename enable_if
   4378 <
   4379     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4380     __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4381 >::type
   4382 operator<(const _Expr1& __x, const _Expr2& __y)
   4383 {
   4384     typedef typename _Expr1::value_type value_type;
   4385     typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
   4386     return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
   4387 }
   4388 
   4389 template<class _Expr>
   4390 inline _LIBCPP_INLINE_VISIBILITY
   4391 typename enable_if
   4392 <
   4393     __is_val_expr<_Expr>::value,
   4394     __val_expr<_BinaryOp<less<typename _Expr::value_type>,
   4395                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4396 >::type
   4397 operator<(const _Expr& __x, const typename _Expr::value_type& __y)
   4398 {
   4399     typedef typename _Expr::value_type value_type;
   4400     typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4401     return __val_expr<_Op>(_Op(less<value_type>(),
   4402                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4403 }
   4404 
   4405 template<class _Expr>
   4406 inline _LIBCPP_INLINE_VISIBILITY
   4407 typename enable_if
   4408 <
   4409     __is_val_expr<_Expr>::value,
   4410     __val_expr<_BinaryOp<less<typename _Expr::value_type>,
   4411                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4412 >::type
   4413 operator<(const typename _Expr::value_type& __x, const _Expr& __y)
   4414 {
   4415     typedef typename _Expr::value_type value_type;
   4416     typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4417     return __val_expr<_Op>(_Op(less<value_type>(),
   4418                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4419 }
   4420 
   4421 template<class _Expr1, class _Expr2>
   4422 inline _LIBCPP_INLINE_VISIBILITY
   4423 typename enable_if
   4424 <
   4425     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4426     __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4427 >::type
   4428 operator>(const _Expr1& __x, const _Expr2& __y)
   4429 {
   4430     typedef typename _Expr1::value_type value_type;
   4431     typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
   4432     return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
   4433 }
   4434 
   4435 template<class _Expr>
   4436 inline _LIBCPP_INLINE_VISIBILITY
   4437 typename enable_if
   4438 <
   4439     __is_val_expr<_Expr>::value,
   4440     __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
   4441                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4442 >::type
   4443 operator>(const _Expr& __x, const typename _Expr::value_type& __y)
   4444 {
   4445     typedef typename _Expr::value_type value_type;
   4446     typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4447     return __val_expr<_Op>(_Op(greater<value_type>(),
   4448                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4449 }
   4450 
   4451 template<class _Expr>
   4452 inline _LIBCPP_INLINE_VISIBILITY
   4453 typename enable_if
   4454 <
   4455     __is_val_expr<_Expr>::value,
   4456     __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
   4457                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4458 >::type
   4459 operator>(const typename _Expr::value_type& __x, const _Expr& __y)
   4460 {
   4461     typedef typename _Expr::value_type value_type;
   4462     typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4463     return __val_expr<_Op>(_Op(greater<value_type>(),
   4464                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4465 }
   4466 
   4467 template<class _Expr1, class _Expr2>
   4468 inline _LIBCPP_INLINE_VISIBILITY
   4469 typename enable_if
   4470 <
   4471     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4472     __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4473 >::type
   4474 operator<=(const _Expr1& __x, const _Expr2& __y)
   4475 {
   4476     typedef typename _Expr1::value_type value_type;
   4477     typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
   4478     return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
   4479 }
   4480 
   4481 template<class _Expr>
   4482 inline _LIBCPP_INLINE_VISIBILITY
   4483 typename enable_if
   4484 <
   4485     __is_val_expr<_Expr>::value,
   4486     __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
   4487                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4488 >::type
   4489 operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
   4490 {
   4491     typedef typename _Expr::value_type value_type;
   4492     typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4493     return __val_expr<_Op>(_Op(less_equal<value_type>(),
   4494                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4495 }
   4496 
   4497 template<class _Expr>
   4498 inline _LIBCPP_INLINE_VISIBILITY
   4499 typename enable_if
   4500 <
   4501     __is_val_expr<_Expr>::value,
   4502     __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
   4503                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4504 >::type
   4505 operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
   4506 {
   4507     typedef typename _Expr::value_type value_type;
   4508     typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4509     return __val_expr<_Op>(_Op(less_equal<value_type>(),
   4510                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4511 }
   4512 
   4513 template<class _Expr1, class _Expr2>
   4514 inline _LIBCPP_INLINE_VISIBILITY
   4515 typename enable_if
   4516 <
   4517     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4518     __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4519 >::type
   4520 operator>=(const _Expr1& __x, const _Expr2& __y)
   4521 {
   4522     typedef typename _Expr1::value_type value_type;
   4523     typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
   4524     return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
   4525 }
   4526 
   4527 template<class _Expr>
   4528 inline _LIBCPP_INLINE_VISIBILITY
   4529 typename enable_if
   4530 <
   4531     __is_val_expr<_Expr>::value,
   4532     __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
   4533                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4534 >::type
   4535 operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
   4536 {
   4537     typedef typename _Expr::value_type value_type;
   4538     typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4539     return __val_expr<_Op>(_Op(greater_equal<value_type>(),
   4540                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4541 }
   4542 
   4543 template<class _Expr>
   4544 inline _LIBCPP_INLINE_VISIBILITY
   4545 typename enable_if
   4546 <
   4547     __is_val_expr<_Expr>::value,
   4548     __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
   4549                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4550 >::type
   4551 operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
   4552 {
   4553     typedef typename _Expr::value_type value_type;
   4554     typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4555     return __val_expr<_Op>(_Op(greater_equal<value_type>(),
   4556                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4557 }
   4558 
   4559 template<class _Expr>
   4560 inline _LIBCPP_INLINE_VISIBILITY
   4561 typename enable_if
   4562 <
   4563     __is_val_expr<_Expr>::value,
   4564     __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
   4565 >::type
   4566 abs(const _Expr& __x)
   4567 {
   4568     typedef typename _Expr::value_type value_type;
   4569     typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
   4570     return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
   4571 }
   4572 
   4573 template<class _Expr>
   4574 inline _LIBCPP_INLINE_VISIBILITY
   4575 typename enable_if
   4576 <
   4577     __is_val_expr<_Expr>::value,
   4578     __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
   4579 >::type
   4580 acos(const _Expr& __x)
   4581 {
   4582     typedef typename _Expr::value_type value_type;
   4583     typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
   4584     return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
   4585 }
   4586 
   4587 template<class _Expr>
   4588 inline _LIBCPP_INLINE_VISIBILITY
   4589 typename enable_if
   4590 <
   4591     __is_val_expr<_Expr>::value,
   4592     __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
   4593 >::type
   4594 asin(const _Expr& __x)
   4595 {
   4596     typedef typename _Expr::value_type value_type;
   4597     typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
   4598     return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
   4599 }
   4600 
   4601 template<class _Expr>
   4602 inline _LIBCPP_INLINE_VISIBILITY
   4603 typename enable_if
   4604 <
   4605     __is_val_expr<_Expr>::value,
   4606     __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
   4607 >::type
   4608 atan(const _Expr& __x)
   4609 {
   4610     typedef typename _Expr::value_type value_type;
   4611     typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
   4612     return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
   4613 }
   4614 
   4615 template<class _Expr1, class _Expr2>
   4616 inline _LIBCPP_INLINE_VISIBILITY
   4617 typename enable_if
   4618 <
   4619     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4620     __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4621 >::type
   4622 atan2(const _Expr1& __x, const _Expr2& __y)
   4623 {
   4624     typedef typename _Expr1::value_type value_type;
   4625     typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
   4626     return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
   4627 }
   4628 
   4629 template<class _Expr>
   4630 inline _LIBCPP_INLINE_VISIBILITY
   4631 typename enable_if
   4632 <
   4633     __is_val_expr<_Expr>::value,
   4634     __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
   4635                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4636 >::type
   4637 atan2(const _Expr& __x, const typename _Expr::value_type& __y)
   4638 {
   4639     typedef typename _Expr::value_type value_type;
   4640     typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4641     return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
   4642                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4643 }
   4644 
   4645 template<class _Expr>
   4646 inline _LIBCPP_INLINE_VISIBILITY
   4647 typename enable_if
   4648 <
   4649     __is_val_expr<_Expr>::value,
   4650     __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
   4651                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4652 >::type
   4653 atan2(const typename _Expr::value_type& __x, const _Expr& __y)
   4654 {
   4655     typedef typename _Expr::value_type value_type;
   4656     typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4657     return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
   4658                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4659 }
   4660 
   4661 template<class _Expr>
   4662 inline _LIBCPP_INLINE_VISIBILITY
   4663 typename enable_if
   4664 <
   4665     __is_val_expr<_Expr>::value,
   4666     __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
   4667 >::type
   4668 cos(const _Expr& __x)
   4669 {
   4670     typedef typename _Expr::value_type value_type;
   4671     typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
   4672     return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
   4673 }
   4674 
   4675 template<class _Expr>
   4676 inline _LIBCPP_INLINE_VISIBILITY
   4677 typename enable_if
   4678 <
   4679     __is_val_expr<_Expr>::value,
   4680     __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
   4681 >::type
   4682 cosh(const _Expr& __x)
   4683 {
   4684     typedef typename _Expr::value_type value_type;
   4685     typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
   4686     return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
   4687 }
   4688 
   4689 template<class _Expr>
   4690 inline _LIBCPP_INLINE_VISIBILITY
   4691 typename enable_if
   4692 <
   4693     __is_val_expr<_Expr>::value,
   4694     __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
   4695 >::type
   4696 exp(const _Expr& __x)
   4697 {
   4698     typedef typename _Expr::value_type value_type;
   4699     typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
   4700     return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
   4701 }
   4702 
   4703 template<class _Expr>
   4704 inline _LIBCPP_INLINE_VISIBILITY
   4705 typename enable_if
   4706 <
   4707     __is_val_expr<_Expr>::value,
   4708     __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
   4709 >::type
   4710 log(const _Expr& __x)
   4711 {
   4712     typedef typename _Expr::value_type value_type;
   4713     typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
   4714     return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
   4715 }
   4716 
   4717 template<class _Expr>
   4718 inline _LIBCPP_INLINE_VISIBILITY
   4719 typename enable_if
   4720 <
   4721     __is_val_expr<_Expr>::value,
   4722     __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
   4723 >::type
   4724 log10(const _Expr& __x)
   4725 {
   4726     typedef typename _Expr::value_type value_type;
   4727     typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
   4728     return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
   4729 }
   4730 
   4731 template<class _Expr1, class _Expr2>
   4732 inline _LIBCPP_INLINE_VISIBILITY
   4733 typename enable_if
   4734 <
   4735     __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
   4736     __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
   4737 >::type
   4738 pow(const _Expr1& __x, const _Expr2& __y)
   4739 {
   4740     typedef typename _Expr1::value_type value_type;
   4741     typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
   4742     return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
   4743 }
   4744 
   4745 template<class _Expr>
   4746 inline _LIBCPP_INLINE_VISIBILITY
   4747 typename enable_if
   4748 <
   4749     __is_val_expr<_Expr>::value,
   4750     __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
   4751                _Expr, __scalar_expr<typename _Expr::value_type> > >
   4752 >::type
   4753 pow(const _Expr& __x, const typename _Expr::value_type& __y)
   4754 {
   4755     typedef typename _Expr::value_type value_type;
   4756     typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
   4757     return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
   4758                            __x, __scalar_expr<value_type>(__y, __x.size())));
   4759 }
   4760 
   4761 template<class _Expr>
   4762 inline _LIBCPP_INLINE_VISIBILITY
   4763 typename enable_if
   4764 <
   4765     __is_val_expr<_Expr>::value,
   4766     __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
   4767                __scalar_expr<typename _Expr::value_type>, _Expr> >
   4768 >::type
   4769 pow(const typename _Expr::value_type& __x, const _Expr& __y)
   4770 {
   4771     typedef typename _Expr::value_type value_type;
   4772     typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
   4773     return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
   4774                            __scalar_expr<value_type>(__x, __y.size()), __y));
   4775 }
   4776 
   4777 template<class _Expr>
   4778 inline _LIBCPP_INLINE_VISIBILITY
   4779 typename enable_if
   4780 <
   4781     __is_val_expr<_Expr>::value,
   4782     __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
   4783 >::type
   4784 sin(const _Expr& __x)
   4785 {
   4786     typedef typename _Expr::value_type value_type;
   4787     typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
   4788     return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
   4789 }
   4790 
   4791 template<class _Expr>
   4792 inline _LIBCPP_INLINE_VISIBILITY
   4793 typename enable_if
   4794 <
   4795     __is_val_expr<_Expr>::value,
   4796     __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
   4797 >::type
   4798 sinh(const _Expr& __x)
   4799 {
   4800     typedef typename _Expr::value_type value_type;
   4801     typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
   4802     return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
   4803 }
   4804 
   4805 template<class _Expr>
   4806 inline _LIBCPP_INLINE_VISIBILITY
   4807 typename enable_if
   4808 <
   4809     __is_val_expr<_Expr>::value,
   4810     __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
   4811 >::type
   4812 sqrt(const _Expr& __x)
   4813 {
   4814     typedef typename _Expr::value_type value_type;
   4815     typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
   4816     return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
   4817 }
   4818 
   4819 template<class _Expr>
   4820 inline _LIBCPP_INLINE_VISIBILITY
   4821 typename enable_if
   4822 <
   4823     __is_val_expr<_Expr>::value,
   4824     __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
   4825 >::type
   4826 tan(const _Expr& __x)
   4827 {
   4828     typedef typename _Expr::value_type value_type;
   4829     typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
   4830     return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
   4831 }
   4832 
   4833 template<class _Expr>
   4834 inline _LIBCPP_INLINE_VISIBILITY
   4835 typename enable_if
   4836 <
   4837     __is_val_expr<_Expr>::value,
   4838     __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
   4839 >::type
   4840 tanh(const _Expr& __x)
   4841 {
   4842     typedef typename _Expr::value_type value_type;
   4843     typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
   4844     return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
   4845 }
   4846 
   4847 template <class _Tp>
   4848 inline _LIBCPP_INLINE_VISIBILITY
   4849 _Tp*
   4850 begin(valarray<_Tp>& __v)
   4851 {
   4852     return __v.__begin_;
   4853 }
   4854 
   4855 template <class _Tp>
   4856 inline _LIBCPP_INLINE_VISIBILITY
   4857 const _Tp*
   4858 begin(const valarray<_Tp>& __v)
   4859 {
   4860     return __v.__begin_;
   4861 }
   4862 
   4863 template <class _Tp>
   4864 inline _LIBCPP_INLINE_VISIBILITY
   4865 _Tp*
   4866 end(valarray<_Tp>& __v)
   4867 {
   4868     return __v.__end_;
   4869 }
   4870 
   4871 template <class _Tp>
   4872 inline _LIBCPP_INLINE_VISIBILITY
   4873 const _Tp*
   4874 end(const valarray<_Tp>& __v)
   4875 {
   4876     return __v.__end_;
   4877 }
   4878 
   4879 _LIBCPP_END_NAMESPACE_STD
   4880 
   4881 #endif  // _LIBCPP_VALARRAY
   4882