brintos

brintos / llvm-project-archived public Read only

0
0
Text · 118.8 KiB · 869bc30 Raw
3198 lines · plain
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___CXX03_VALARRAY11#define _LIBCPP___CXX03_VALARRAY12 13/*14    valarray synopsis15 16namespace std17{18 19template<class T>20class valarray21{22public:23    typedef T value_type;24 25    // construct/destroy:26    valarray();27    explicit valarray(size_t n);28    valarray(const value_type& x, size_t n);29    valarray(const value_type* px, size_t n);30    valarray(const valarray& v);31    valarray(valarray&& v) noexcept;32    valarray(const slice_array<value_type>& sa);33    valarray(const gslice_array<value_type>& ga);34    valarray(const mask_array<value_type>& ma);35    valarray(const indirect_array<value_type>& ia);36    valarray(initializer_list<value_type> il);37    ~valarray();38 39    // assignment:40    valarray& operator=(const valarray& v);41    valarray& operator=(valarray&& v) noexcept;42    valarray& operator=(initializer_list<value_type> il);43    valarray& operator=(const value_type& x);44    valarray& operator=(const slice_array<value_type>& sa);45    valarray& operator=(const gslice_array<value_type>& ga);46    valarray& operator=(const mask_array<value_type>& ma);47    valarray& operator=(const indirect_array<value_type>& ia);48 49    // element access:50    const value_type& operator[](size_t i) const;51    value_type&       operator[](size_t i);52 53    // subset operations:54    valarray                   operator[](slice s) const;55    slice_array<value_type>    operator[](slice s);56    valarray                   operator[](const gslice& gs) const;57    gslice_array<value_type>   operator[](const gslice& gs);58    valarray                   operator[](const valarray<bool>& vb) const;59    mask_array<value_type>     operator[](const valarray<bool>& vb);60    valarray                   operator[](const valarray<size_t>& vs) const;61    indirect_array<value_type> operator[](const valarray<size_t>& vs);62 63    // unary operators:64    valarray       operator+() const;65    valarray       operator-() const;66    valarray       operator~() const;67    valarray<bool> operator!() const;68 69    // computed assignment:70    valarray& operator*= (const value_type& x);71    valarray& operator/= (const value_type& x);72    valarray& operator%= (const value_type& x);73    valarray& operator+= (const value_type& x);74    valarray& operator-= (const value_type& x);75    valarray& operator^= (const value_type& x);76    valarray& operator&= (const value_type& x);77    valarray& operator|= (const value_type& x);78    valarray& operator<<=(const value_type& x);79    valarray& operator>>=(const value_type& x);80 81    valarray& operator*= (const valarray& v);82    valarray& operator/= (const valarray& v);83    valarray& operator%= (const valarray& v);84    valarray& operator+= (const valarray& v);85    valarray& operator-= (const valarray& v);86    valarray& operator^= (const valarray& v);87    valarray& operator|= (const valarray& v);88    valarray& operator&= (const valarray& v);89    valarray& operator<<=(const valarray& v);90    valarray& operator>>=(const valarray& v);91 92    // member functions:93    void swap(valarray& v) noexcept;94 95    size_t size() const;96 97    value_type sum() const;98    value_type min() const;99    value_type max() const;100 101    valarray shift (int i) const;102    valarray cshift(int i) const;103    valarray apply(value_type f(value_type)) const;104    valarray apply(value_type f(const value_type&)) const;105    void resize(size_t n, value_type x = value_type());106};107 108template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>;109 110class slice111{112public:113    slice();114    slice(size_t start, size_t size, size_t stride);115 116    size_t start()  const;117    size_t size()   const;118    size_t stride() const;119 120    friend bool operator==(const slice& x, const slice& y); // since C++20121};122 123template <class T>124class slice_array125{126public:127    typedef T value_type;128 129    const slice_array& operator=(const slice_array& sa) const;130    void operator=  (const valarray<value_type>& v) const;131    void operator*= (const valarray<value_type>& v) const;132    void operator/= (const valarray<value_type>& v) const;133    void operator%= (const valarray<value_type>& v) const;134    void operator+= (const valarray<value_type>& v) const;135    void operator-= (const valarray<value_type>& v) const;136    void operator^= (const valarray<value_type>& v) const;137    void operator&= (const valarray<value_type>& v) const;138    void operator|= (const valarray<value_type>& v) const;139    void operator<<=(const valarray<value_type>& v) const;140    void operator>>=(const valarray<value_type>& v) const;141 142    void operator=(const value_type& x) const;143    void operator=(const valarray<T>& val_arr) const;144 145    slice_array() = delete;146};147 148class gslice149{150public:151    gslice();152    gslice(size_t start, const valarray<size_t>& size,153                         const valarray<size_t>& stride);154 155    size_t           start()  const;156    valarray<size_t> size()   const;157    valarray<size_t> stride() const;158};159 160template <class T>161class gslice_array162{163public:164    typedef T value_type;165 166    void operator=  (const valarray<value_type>& v) const;167    void operator*= (const valarray<value_type>& v) const;168    void operator/= (const valarray<value_type>& v) const;169    void operator%= (const valarray<value_type>& v) const;170    void operator+= (const valarray<value_type>& v) const;171    void operator-= (const valarray<value_type>& v) const;172    void operator^= (const valarray<value_type>& v) const;173    void operator&= (const valarray<value_type>& v) const;174    void operator|= (const valarray<value_type>& v) const;175    void operator<<=(const valarray<value_type>& v) const;176    void operator>>=(const valarray<value_type>& v) const;177 178    gslice_array(const gslice_array& ga);179    ~gslice_array();180    const gslice_array& operator=(const gslice_array& ga) const;181    void operator=(const value_type& x) const;182 183    gslice_array() = delete;184};185 186template <class T>187class mask_array188{189public:190    typedef T value_type;191 192    void operator=  (const valarray<value_type>& v) const;193    void operator*= (const valarray<value_type>& v) const;194    void operator/= (const valarray<value_type>& v) const;195    void operator%= (const valarray<value_type>& v) const;196    void operator+= (const valarray<value_type>& v) const;197    void operator-= (const valarray<value_type>& v) const;198    void operator^= (const valarray<value_type>& v) const;199    void operator&= (const valarray<value_type>& v) const;200    void operator|= (const valarray<value_type>& v) const;201    void operator<<=(const valarray<value_type>& v) const;202    void operator>>=(const valarray<value_type>& v) const;203 204    mask_array(const mask_array& ma);205    ~mask_array();206    const mask_array& operator=(const mask_array& ma) const;207    void operator=(const value_type& x) const;208 209    mask_array() = delete;210};211 212template <class T>213class indirect_array214{215public:216    typedef T value_type;217 218    void operator=  (const valarray<value_type>& v) const;219    void operator*= (const valarray<value_type>& v) const;220    void operator/= (const valarray<value_type>& v) const;221    void operator%= (const valarray<value_type>& v) const;222    void operator+= (const valarray<value_type>& v) const;223    void operator-= (const valarray<value_type>& v) const;224    void operator^= (const valarray<value_type>& v) const;225    void operator&= (const valarray<value_type>& v) const;226    void operator|= (const valarray<value_type>& v) const;227    void operator<<=(const valarray<value_type>& v) const;228    void operator>>=(const valarray<value_type>& v) const;229 230    indirect_array(const indirect_array& ia);231    ~indirect_array();232    const indirect_array& operator=(const indirect_array& ia) const;233    void operator=(const value_type& x) const;234 235    indirect_array() = delete;236};237 238template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;239 240template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);241template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);242template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);243 244template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);245template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);246template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);247 248template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);249template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);250template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);251 252template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);253template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);254template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);255 256template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);257template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);258template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);259 260template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);261template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);262template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);263 264template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);265template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);266template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);267 268template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);269template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);270template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);271 272template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);273template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);274template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);275 276template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);277template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);278template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);279 280template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);281template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);282template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);283 284template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);285template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);286template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);287 288template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);289template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);290template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);291 292template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);293template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);294template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);295 296template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);297template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);298template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);299 300template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);301template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);302template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);303 304template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);305template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);306template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);307 308template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);309template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);310template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);311 312template<class T> valarray<T> abs (const valarray<T>& x);313template<class T> valarray<T> acos (const valarray<T>& x);314template<class T> valarray<T> asin (const valarray<T>& x);315template<class T> valarray<T> atan (const valarray<T>& x);316 317template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);318template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);319template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);320 321template<class T> valarray<T> cos (const valarray<T>& x);322template<class T> valarray<T> cosh (const valarray<T>& x);323template<class T> valarray<T> exp (const valarray<T>& x);324template<class T> valarray<T> log (const valarray<T>& x);325template<class T> valarray<T> log10(const valarray<T>& x);326 327template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);328template<class T> valarray<T> pow(const valarray<T>& x, const T& y);329template<class T> valarray<T> pow(const T& x, const valarray<T>& y);330 331template<class T> valarray<T> sin (const valarray<T>& x);332template<class T> valarray<T> sinh (const valarray<T>& x);333template<class T> valarray<T> sqrt (const valarray<T>& x);334template<class T> valarray<T> tan (const valarray<T>& x);335template<class T> valarray<T> tanh (const valarray<T>& x);336 337template <class T> unspecified1 begin(valarray<T>& v);338template <class T> unspecified2 begin(const valarray<T>& v);339template <class T> unspecified1 end(valarray<T>& v);340template <class T> unspecified2 end(const valarray<T>& v);341 342}  // std343 344*/345 346#include <__cxx03/__algorithm/copy.h>347#include <__cxx03/__algorithm/count.h>348#include <__cxx03/__algorithm/fill.h>349#include <__cxx03/__algorithm/max_element.h>350#include <__cxx03/__algorithm/min.h>351#include <__cxx03/__algorithm/min_element.h>352#include <__cxx03/__algorithm/unwrap_iter.h>353#include <__cxx03/__assert>354#include <__cxx03/__config>355#include <__cxx03/__functional/operations.h>356#include <__cxx03/__memory/addressof.h>357#include <__cxx03/__memory/allocator.h>358#include <__cxx03/__memory/uninitialized_algorithms.h>359#include <__cxx03/__type_traits/decay.h>360#include <__cxx03/__type_traits/remove_reference.h>361#include <__cxx03/__utility/move.h>362#include <__cxx03/__utility/swap.h>363#include <__cxx03/cmath>364#include <__cxx03/cstddef>365#include <__cxx03/new>366#include <__cxx03/version>367 368#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)369#  pragma GCC system_header370#endif371 372_LIBCPP_PUSH_MACROS373#include <__cxx03/__undef_macros>374 375_LIBCPP_BEGIN_NAMESPACE_STD376 377template <class _Tp>378class _LIBCPP_TEMPLATE_VIS valarray;379 380class _LIBCPP_TEMPLATE_VIS slice {381  size_t __start_;382  size_t __size_;383  size_t __stride_;384 385public:386  _LIBCPP_HIDE_FROM_ABI slice() : __start_(0), __size_(0), __stride_(0) {}387 388  _LIBCPP_HIDE_FROM_ABI slice(size_t __start, size_t __size, size_t __stride)389      : __start_(__start), __size_(__size), __stride_(__stride) {}390 391  _LIBCPP_HIDE_FROM_ABI size_t start() const { return __start_; }392  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }393  _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; }394};395 396template <class _Tp>397class _LIBCPP_TEMPLATE_VIS slice_array;398class _LIBCPP_EXPORTED_FROM_ABI gslice;399template <class _Tp>400class _LIBCPP_TEMPLATE_VIS gslice_array;401template <class _Tp>402class _LIBCPP_TEMPLATE_VIS mask_array;403template <class _Tp>404class _LIBCPP_TEMPLATE_VIS indirect_array;405 406template <class _Tp>407_LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v);408 409template <class _Tp>410_LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v);411 412template <class _Tp>413_LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v);414 415template <class _Tp>416_LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v);417 418template <class _Op, class _A0>419struct _UnaryOp {420  typedef typename _Op::__result_type __result_type;421  using value_type = __decay_t<__result_type>;422 423  _Op __op_;424  _A0 __a0_;425 426  _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}427 428  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); }429 430  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }431};432 433template <class _Op, class _A0, class _A1>434struct _BinaryOp {435  typedef typename _Op::__result_type __result_type;436  using value_type = __decay_t<__result_type>;437 438  _Op __op_;439  _A0 __a0_;440  _A1 __a1_;441 442  _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)443      : __op_(__op), __a0_(__a0), __a1_(__a1) {}444 445  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }446 447  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }448};449 450template <class _Tp>451class __scalar_expr {452public:453  typedef _Tp value_type;454  typedef const _Tp& __result_type;455 456private:457  const value_type& __t_;458  size_t __s_;459 460public:461  _LIBCPP_HIDE_FROM_ABI explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}462 463  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t) const { return __t_; }464 465  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __s_; }466};467 468template <class _Tp>469struct __unary_plus {470  typedef _Tp __result_type;471  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return +__x; }472};473 474template <class _Tp>475struct __bit_not {476  typedef _Tp __result_type;477  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }478};479 480template <class _Tp>481struct __bit_shift_left {482  typedef _Tp __result_type;483  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x << __y; }484};485 486template <class _Tp>487struct __bit_shift_right {488  typedef _Tp __result_type;489  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x >> __y; }490};491 492template <class _Tp, class _Fp>493struct __apply_expr {494private:495  _Fp __f_;496 497public:498  typedef _Tp __result_type;499 500  _LIBCPP_HIDE_FROM_ABI explicit __apply_expr(_Fp __f) : __f_(__f) {}501 502  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return __f_(__x); }503};504 505template <class _Tp>506struct __abs_expr {507  typedef _Tp __result_type;508  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::abs(__x); }509};510 511template <class _Tp>512struct __acos_expr {513  typedef _Tp __result_type;514  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::acos(__x); }515};516 517template <class _Tp>518struct __asin_expr {519  typedef _Tp __result_type;520  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::asin(__x); }521};522 523template <class _Tp>524struct __atan_expr {525  typedef _Tp __result_type;526  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::atan(__x); }527};528 529template <class _Tp>530struct __atan2_expr {531  typedef _Tp __result_type;532  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::atan2(__x, __y); }533};534 535template <class _Tp>536struct __cos_expr {537  typedef _Tp __result_type;538  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cos(__x); }539};540 541template <class _Tp>542struct __cosh_expr {543  typedef _Tp __result_type;544  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cosh(__x); }545};546 547template <class _Tp>548struct __exp_expr {549  typedef _Tp __result_type;550  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::exp(__x); }551};552 553template <class _Tp>554struct __log_expr {555  typedef _Tp __result_type;556  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log(__x); }557};558 559template <class _Tp>560struct __log10_expr {561  typedef _Tp __result_type;562  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log10(__x); }563};564 565template <class _Tp>566struct __pow_expr {567  typedef _Tp __result_type;568  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::pow(__x, __y); }569};570 571template <class _Tp>572struct __sin_expr {573  typedef _Tp __result_type;574  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sin(__x); }575};576 577template <class _Tp>578struct __sinh_expr {579  typedef _Tp __result_type;580  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sinh(__x); }581};582 583template <class _Tp>584struct __sqrt_expr {585  typedef _Tp __result_type;586  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sqrt(__x); }587};588 589template <class _Tp>590struct __tan_expr {591  typedef _Tp __result_type;592  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tan(__x); }593};594 595template <class _Tp>596struct __tanh_expr {597  typedef _Tp __result_type;598  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tanh(__x); }599};600 601template <class _ValExpr>602class __slice_expr {603  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;604 605public:606  typedef typename _RmExpr::value_type value_type;607  typedef value_type __result_type;608 609private:610  _ValExpr __expr_;611  size_t __start_;612  size_t __size_;613  size_t __stride_;614 615  _LIBCPP_HIDE_FROM_ABI __slice_expr(const slice& __sl, const _RmExpr& __e)616      : __expr_(__e), __start_(__sl.start()), __size_(__sl.size()), __stride_(__sl.stride()) {}617 618public:619  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__start_ + __i * __stride_]; }620 621  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }622 623  template <class>624  friend class __val_expr;625  template <class>626  friend class _LIBCPP_TEMPLATE_VIS valarray;627};628 629template <class _ValExpr>630class __mask_expr;631 632template <class _ValExpr>633class __indirect_expr;634 635template <class _ValExpr>636class __shift_expr {637  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;638 639public:640  typedef typename _RmExpr::value_type value_type;641  typedef value_type __result_type;642 643private:644  _ValExpr __expr_;645  size_t __size_;646  ptrdiff_t __ul_;647  ptrdiff_t __sn_;648  ptrdiff_t __n_;649  static const ptrdiff_t _Np = static_cast<ptrdiff_t>(sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);650 651  _LIBCPP_HIDE_FROM_ABI __shift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()), __n_(__n) {652    ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);653    __sn_             = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);654    __ul_             = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);655  }656 657public:658  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __j) const {659    ptrdiff_t __i = static_cast<ptrdiff_t>(__j);660    ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;661    return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);662  }663 664  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }665 666  template <class>667  friend class __val_expr;668};669 670template <class _ValExpr>671class __cshift_expr {672  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;673 674public:675  typedef typename _RmExpr::value_type value_type;676  typedef value_type __result_type;677 678private:679  _ValExpr __expr_;680  size_t __size_;681  size_t __m_;682  size_t __o1_;683  size_t __o2_;684 685  _LIBCPP_HIDE_FROM_ABI __cshift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()) {686    __n %= static_cast<int>(__size_);687    if (__n >= 0) {688      __m_  = __size_ - __n;689      __o1_ = __n;690      __o2_ = __n - __size_;691    } else {692      __m_  = -__n;693      __o1_ = __n + __size_;694      __o2_ = __n;695    }696  }697 698public:699  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const {700    if (__i < __m_)701      return __expr_[__i + __o1_];702    return __expr_[__i + __o2_];703  }704 705  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }706 707  template <class>708  friend class __val_expr;709};710 711template <class _ValExpr>712class __val_expr;713 714template <class _ValExpr>715struct __is_val_expr : false_type {};716 717template <class _ValExpr>718struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};719 720template <class _Tp>721struct __is_val_expr<valarray<_Tp> > : true_type {};722 723template <class _Tp>724struct __is_val_expr<slice_array<_Tp> > : true_type {};725 726template <class _Tp>727struct __is_val_expr<gslice_array<_Tp> > : true_type {};728 729template <class _Tp>730struct __is_val_expr<mask_array<_Tp> > : true_type {};731 732template <class _Tp>733struct __is_val_expr<indirect_array<_Tp> > : true_type {};734 735// The functions using a __val_expr access the elements by their index.736// valarray and the libc++ lazy proxies have an operator[]. The737// Standard proxy array's don't have this operator, instead they have a738// implementation specific accessor739//   __get(size_t)740//741// The functions use the non-member function742//   __get(__val_expr, size_t)743//744// If the __val_expr is a specialization of __val_expr_use_member_functions it745// uses the __val_expr's member function746//   __get(size_t)747// else it uses the __val_expr's member function748//   operator[](size_t)749template <class _ValExpr>750struct __val_expr_use_member_functions;751 752template <class>753struct __val_expr_use_member_functions : false_type {};754 755template <class _Tp>756struct __val_expr_use_member_functions<slice_array<_Tp> > : true_type {};757 758template <class _Tp>759struct __val_expr_use_member_functions<gslice_array<_Tp> > : true_type {};760 761template <class _Tp>762struct __val_expr_use_member_functions<mask_array<_Tp> > : true_type {};763 764template <class _Tp>765struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {};766 767template <class _Tp>768class _LIBCPP_TEMPLATE_VIS valarray {769public:770  typedef _Tp value_type;771  typedef _Tp __result_type;772 773private:774  value_type* __begin_;775  value_type* __end_;776 777public:778  // construct/destroy:779  _LIBCPP_HIDE_FROM_ABI valarray() : __begin_(nullptr), __end_(nullptr) {}780  inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit valarray(size_t __n);781  _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n);782  valarray(const value_type* __p, size_t __n);783  valarray(const valarray& __v);784  valarray(const slice_array<value_type>& __sa);785  valarray(const gslice_array<value_type>& __ga);786  valarray(const mask_array<value_type>& __ma);787  valarray(const indirect_array<value_type>& __ia);788  inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 ~valarray();789 790  // assignment:791  valarray& operator=(const valarray& __v);792  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x);793  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa);794  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga);795  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const mask_array<value_type>& __ma);796  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const indirect_array<value_type>& __ia);797  template <class _ValExpr>798  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v);799 800  // element access:801  _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { return __begin_[__i]; }802 803  _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { return __begin_[__i]; }804 805  // subset operations:806  _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;807  _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s);808  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;809  _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs);810  _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;811  _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb);812  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;813  _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs);814 815  // unary operators:816  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;817  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const;818  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const;819  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const;820 821  // computed assignment:822  _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const value_type& __x);823  _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const value_type& __x);824  _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const value_type& __x);825  _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const value_type& __x);826  _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const value_type& __x);827  _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const value_type& __x);828  _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const value_type& __x);829  _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const value_type& __x);830  _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const value_type& __x);831  _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const value_type& __x);832 833  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>834  _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const _Expr& __v);835 836  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>837  _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const _Expr& __v);838 839  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>840  _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const _Expr& __v);841 842  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>843  _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const _Expr& __v);844 845  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>846  _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const _Expr& __v);847 848  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>849  _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const _Expr& __v);850 851  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>852  _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const _Expr& __v);853 854  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>855  _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const _Expr& __v);856 857  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>858  _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const _Expr& __v);859 860  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>861  _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const _Expr& __v);862 863  // member functions:864  _LIBCPP_HIDE_FROM_ABI void swap(valarray& __v) _NOEXCEPT;865 866  _LIBCPP_HIDE_FROM_ABI size_t size() const { return static_cast<size_t>(__end_ - __begin_); }867 868  _LIBCPP_HIDE_FROM_ABI value_type sum() const;869  _LIBCPP_HIDE_FROM_ABI value_type min() const;870  _LIBCPP_HIDE_FROM_ABI value_type max() const;871 872  valarray shift(int __i) const;873  valarray cshift(int __i) const;874  valarray apply(value_type __f(value_type)) const;875  valarray apply(value_type __f(const value_type&)) const;876  void resize(size_t __n, value_type __x = value_type());877 878private:879  template <class>880  friend class _LIBCPP_TEMPLATE_VIS valarray;881  template <class>882  friend class _LIBCPP_TEMPLATE_VIS slice_array;883  template <class>884  friend class _LIBCPP_TEMPLATE_VIS gslice_array;885  template <class>886  friend class _LIBCPP_TEMPLATE_VIS mask_array;887  template <class>888  friend class __mask_expr;889  template <class>890  friend class _LIBCPP_TEMPLATE_VIS indirect_array;891  template <class>892  friend class __indirect_expr;893  template <class>894  friend class __val_expr;895 896  template <class _Up>897  friend _Up* begin(valarray<_Up>& __v);898 899  template <class _Up>900  friend const _Up* begin(const valarray<_Up>& __v);901 902  template <class _Up>903  friend _Up* end(valarray<_Up>& __v);904 905  template <class _Up>906  friend const _Up* end(const valarray<_Up>& __v);907 908  _LIBCPP_HIDE_FROM_ABI void __clear(size_t __capacity);909  valarray& __assign_range(const value_type* __f, const value_type* __l);910};911 912template <class _Expr,913          __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0>914_LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {915  return __v.__get(__i);916}917 918template <class _Expr,919          __enable_if_t<__is_val_expr<_Expr>::value && !__val_expr_use_member_functions<_Expr>::value, int> = 0>920_LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {921  return __v[__i];922}923 924extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t);925 926template <class _Op, class _Tp>927struct _UnaryOp<_Op, valarray<_Tp> > {928  typedef typename _Op::__result_type __result_type;929  using value_type = __decay_t<__result_type>;930 931  _Op __op_;932  const valarray<_Tp>& __a0_;933 934  _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}935 936  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); }937 938  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }939};940 941template <class _Op, class _Tp, class _A1>942struct _BinaryOp<_Op, valarray<_Tp>, _A1> {943  typedef typename _Op::__result_type __result_type;944  using value_type = __decay_t<__result_type>;945 946  _Op __op_;947  const valarray<_Tp>& __a0_;948  _A1 __a1_;949 950  _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)951      : __op_(__op), __a0_(__a0), __a1_(__a1) {}952 953  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }954 955  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }956};957 958template <class _Op, class _A0, class _Tp>959struct _BinaryOp<_Op, _A0, valarray<_Tp> > {960  typedef typename _Op::__result_type __result_type;961  using value_type = __decay_t<__result_type>;962 963  _Op __op_;964  _A0 __a0_;965  const valarray<_Tp>& __a1_;966 967  _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)968      : __op_(__op), __a0_(__a0), __a1_(__a1) {}969 970  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }971 972  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }973};974 975template <class _Op, class _Tp>976struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > {977  typedef typename _Op::__result_type __result_type;978  using value_type = __decay_t<__result_type>;979 980  _Op __op_;981  const valarray<_Tp>& __a0_;982  const valarray<_Tp>& __a1_;983 984  _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)985      : __op_(__op), __a0_(__a0), __a1_(__a1) {}986 987  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }988 989  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }990};991 992// slice_array993 994template <class _Tp>995class _LIBCPP_TEMPLATE_VIS slice_array {996public:997  typedef _Tp value_type;998 999private:1000  value_type* __vp_;1001  size_t __size_;1002  size_t __stride_;1003 1004public:1005  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1006  void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;1007 1008  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1009  void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;1010 1011  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1012  void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;1013 1014  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1015  void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;1016 1017  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1018  void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;1019 1020  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1021  void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;1022 1023  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1024  void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;1025 1026  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1027  void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;1028 1029  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1030  void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;1031 1032  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1033  void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;1034 1035  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1036  void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;1037 1038  slice_array(slice_array const&) = default;1039 1040  _LIBCPP_HIDE_FROM_ABI const slice_array& operator=(const slice_array& __sa) const;1041 1042  _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;1043 1044  _LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const;1045 1046  // Behaves like __val_expr::operator[], which returns by value.1047  _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {1048    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "slice_array.__get() index out of bounds");1049    return __vp_[__i * __stride_];1050  }1051 1052private:1053  _LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v)1054      : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {}1055 1056  template <class>1057  friend class valarray;1058};1059 1060template <class _Tp>1061inline const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const {1062  value_type* __t       = __vp_;1063  const value_type* __s = __sa.__vp_;1064  for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)1065    *__t = *__s;1066  return *this;1067}1068 1069template <class _Tp>1070template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1071inline void slice_array<_Tp>::operator=(const _Expr& __v) const {1072  value_type* __t = __vp_;1073  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1074    *__t = __v[__i];1075}1076 1077template <class _Tp>1078inline void slice_array<_Tp>::operator=(const valarray<value_type>& __va) const {1079  value_type* __t = __vp_;1080  for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)1081    *__t = __va[__i];1082}1083 1084template <class _Tp>1085template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1086inline void slice_array<_Tp>::operator*=(const _Expr& __v) const {1087  value_type* __t = __vp_;1088  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1089    *__t *= __v[__i];1090}1091 1092template <class _Tp>1093template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1094inline void slice_array<_Tp>::operator/=(const _Expr& __v) const {1095  value_type* __t = __vp_;1096  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1097    *__t /= __v[__i];1098}1099 1100template <class _Tp>1101template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1102inline void slice_array<_Tp>::operator%=(const _Expr& __v) const {1103  value_type* __t = __vp_;1104  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1105    *__t %= __v[__i];1106}1107 1108template <class _Tp>1109template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1110inline void slice_array<_Tp>::operator+=(const _Expr& __v) const {1111  value_type* __t = __vp_;1112  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1113    *__t += __v[__i];1114}1115 1116template <class _Tp>1117template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1118inline void slice_array<_Tp>::operator-=(const _Expr& __v) const {1119  value_type* __t = __vp_;1120  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1121    *__t -= __v[__i];1122}1123 1124template <class _Tp>1125template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1126inline void slice_array<_Tp>::operator^=(const _Expr& __v) const {1127  value_type* __t = __vp_;1128  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1129    *__t ^= __v[__i];1130}1131 1132template <class _Tp>1133template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1134inline void slice_array<_Tp>::operator&=(const _Expr& __v) const {1135  value_type* __t = __vp_;1136  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1137    *__t &= __v[__i];1138}1139 1140template <class _Tp>1141template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1142inline void slice_array<_Tp>::operator|=(const _Expr& __v) const {1143  value_type* __t = __vp_;1144  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1145    *__t |= __v[__i];1146}1147 1148template <class _Tp>1149template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1150inline void slice_array<_Tp>::operator<<=(const _Expr& __v) const {1151  value_type* __t = __vp_;1152  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1153    *__t <<= __v[__i];1154}1155 1156template <class _Tp>1157template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1158inline void slice_array<_Tp>::operator>>=(const _Expr& __v) const {1159  value_type* __t = __vp_;1160  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1161    *__t >>= __v[__i];1162}1163 1164template <class _Tp>1165inline void slice_array<_Tp>::operator=(const value_type& __x) const {1166  value_type* __t = __vp_;1167  for (size_t __n = __size_; __n; --__n, __t += __stride_)1168    *__t = __x;1169}1170 1171// gslice1172 1173class _LIBCPP_EXPORTED_FROM_ABI gslice {1174  valarray<size_t> __size_;1175  valarray<size_t> __stride_;1176  valarray<size_t> __1d_;1177 1178public:1179  _LIBCPP_HIDE_FROM_ABI gslice() {}1180 1181  _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, const valarray<size_t>& __stride)1182      : __size_(__size), __stride_(__stride) {1183    __init(__start);1184  }1185 1186  _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; }1187 1188  _LIBCPP_HIDE_FROM_ABI valarray<size_t> size() const { return __size_; }1189 1190  _LIBCPP_HIDE_FROM_ABI valarray<size_t> stride() const { return __stride_; }1191 1192private:1193  void __init(size_t __start);1194 1195  template <class>1196  friend class gslice_array;1197  template <class>1198  friend class valarray;1199  template <class>1200  friend class __val_expr;1201};1202 1203// gslice_array1204 1205template <class _Tp>1206class _LIBCPP_TEMPLATE_VIS gslice_array {1207public:1208  typedef _Tp value_type;1209 1210private:1211  value_type* __vp_;1212  valarray<size_t> __1d_;1213 1214public:1215  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1216  void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;1217 1218  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1219  void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;1220 1221  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1222  void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;1223 1224  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1225  void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;1226 1227  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1228  void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;1229 1230  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1231  void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;1232 1233  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1234  void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;1235 1236  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1237  void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;1238 1239  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1240  void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;1241 1242  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1243  void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;1244 1245  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1246  void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;1247 1248  _LIBCPP_HIDE_FROM_ABI const gslice_array& operator=(const gslice_array& __ga) const;1249 1250  _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;1251 1252  gslice_array(const gslice_array&) = default;1253 1254  // Behaves like __val_expr::operator[], which returns by value.1255  _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {1256    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "gslice_array.__get() index out of bounds");1257    return __vp_[__1d_[__i]];1258  }1259 1260private:1261  gslice_array(const gslice& __gs, const valarray<value_type>& __v)1262      : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {}1263 1264  template <class>1265  friend class valarray;1266};1267 1268template <class _Tp>1269template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1270inline void gslice_array<_Tp>::operator=(const _Expr& __v) const {1271  typedef const size_t* _Ip;1272  size_t __j = 0;1273  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1274    __vp_[*__i] = __v[__j];1275}1276 1277template <class _Tp>1278template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1279inline void gslice_array<_Tp>::operator*=(const _Expr& __v) const {1280  typedef const size_t* _Ip;1281  size_t __j = 0;1282  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1283    __vp_[*__i] *= __v[__j];1284}1285 1286template <class _Tp>1287template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1288inline void gslice_array<_Tp>::operator/=(const _Expr& __v) const {1289  typedef const size_t* _Ip;1290  size_t __j = 0;1291  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1292    __vp_[*__i] /= __v[__j];1293}1294 1295template <class _Tp>1296template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1297inline void gslice_array<_Tp>::operator%=(const _Expr& __v) const {1298  typedef const size_t* _Ip;1299  size_t __j = 0;1300  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1301    __vp_[*__i] %= __v[__j];1302}1303 1304template <class _Tp>1305template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1306inline void gslice_array<_Tp>::operator+=(const _Expr& __v) const {1307  typedef const size_t* _Ip;1308  size_t __j = 0;1309  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1310    __vp_[*__i] += __v[__j];1311}1312 1313template <class _Tp>1314template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1315inline void gslice_array<_Tp>::operator-=(const _Expr& __v) const {1316  typedef const size_t* _Ip;1317  size_t __j = 0;1318  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1319    __vp_[*__i] -= __v[__j];1320}1321 1322template <class _Tp>1323template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1324inline void gslice_array<_Tp>::operator^=(const _Expr& __v) const {1325  typedef const size_t* _Ip;1326  size_t __j = 0;1327  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1328    __vp_[*__i] ^= __v[__j];1329}1330 1331template <class _Tp>1332template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1333inline void gslice_array<_Tp>::operator&=(const _Expr& __v) const {1334  typedef const size_t* _Ip;1335  size_t __j = 0;1336  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1337    __vp_[*__i] &= __v[__j];1338}1339 1340template <class _Tp>1341template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1342inline void gslice_array<_Tp>::operator|=(const _Expr& __v) const {1343  typedef const size_t* _Ip;1344  size_t __j = 0;1345  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1346    __vp_[*__i] |= __v[__j];1347}1348 1349template <class _Tp>1350template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1351inline void gslice_array<_Tp>::operator<<=(const _Expr& __v) const {1352  typedef const size_t* _Ip;1353  size_t __j = 0;1354  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1355    __vp_[*__i] <<= __v[__j];1356}1357 1358template <class _Tp>1359template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1360inline void gslice_array<_Tp>::operator>>=(const _Expr& __v) const {1361  typedef const size_t* _Ip;1362  size_t __j = 0;1363  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1364    __vp_[*__i] >>= __v[__j];1365}1366 1367template <class _Tp>1368inline const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const {1369  typedef const size_t* _Ip;1370  const value_type* __s = __ga.__vp_;1371  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; __i != __e; ++__i, ++__j)1372    __vp_[*__i] = __s[*__j];1373  return *this;1374}1375 1376template <class _Tp>1377inline void gslice_array<_Tp>::operator=(const value_type& __x) const {1378  typedef const size_t* _Ip;1379  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)1380    __vp_[*__i] = __x;1381}1382 1383// mask_array1384 1385template <class _Tp>1386class _LIBCPP_TEMPLATE_VIS mask_array {1387public:1388  typedef _Tp value_type;1389 1390private:1391  value_type* __vp_;1392  valarray<size_t> __1d_;1393 1394public:1395  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1396  void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;1397 1398  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1399  void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;1400 1401  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1402  void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;1403 1404  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1405  void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;1406 1407  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1408  void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;1409 1410  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1411  void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;1412 1413  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1414  void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;1415 1416  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1417  void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;1418 1419  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1420  void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;1421 1422  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1423  void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;1424 1425  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1426  void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;1427 1428  mask_array(const mask_array&) = default;1429 1430  _LIBCPP_HIDE_FROM_ABI const mask_array& operator=(const mask_array& __ma) const;1431 1432  _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;1433 1434  // Behaves like __val_expr::operator[], which returns by value.1435  _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {1436    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "mask_array.__get() index out of bounds");1437    return __vp_[__1d_[__i]];1438  }1439 1440private:1441  _LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)1442      : __vp_(const_cast<value_type*>(__v.__begin_)),1443        __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) {1444    size_t __j = 0;1445    for (size_t __i = 0; __i < __vb.size(); ++__i)1446      if (__vb[__i])1447        __1d_[__j++] = __i;1448  }1449 1450  template <class>1451  friend class valarray;1452};1453 1454template <class _Tp>1455template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1456inline void mask_array<_Tp>::operator=(const _Expr& __v) const {1457  size_t __n = __1d_.size();1458  for (size_t __i = 0; __i < __n; ++__i)1459    __vp_[__1d_[__i]] = __v[__i];1460}1461 1462template <class _Tp>1463template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1464inline void mask_array<_Tp>::operator*=(const _Expr& __v) const {1465  size_t __n = __1d_.size();1466  for (size_t __i = 0; __i < __n; ++__i)1467    __vp_[__1d_[__i]] *= __v[__i];1468}1469 1470template <class _Tp>1471template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1472inline void mask_array<_Tp>::operator/=(const _Expr& __v) const {1473  size_t __n = __1d_.size();1474  for (size_t __i = 0; __i < __n; ++__i)1475    __vp_[__1d_[__i]] /= __v[__i];1476}1477 1478template <class _Tp>1479template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1480inline void mask_array<_Tp>::operator%=(const _Expr& __v) const {1481  size_t __n = __1d_.size();1482  for (size_t __i = 0; __i < __n; ++__i)1483    __vp_[__1d_[__i]] %= __v[__i];1484}1485 1486template <class _Tp>1487template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1488inline void mask_array<_Tp>::operator+=(const _Expr& __v) const {1489  size_t __n = __1d_.size();1490  for (size_t __i = 0; __i < __n; ++__i)1491    __vp_[__1d_[__i]] += __v[__i];1492}1493 1494template <class _Tp>1495template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1496inline void mask_array<_Tp>::operator-=(const _Expr& __v) const {1497  size_t __n = __1d_.size();1498  for (size_t __i = 0; __i < __n; ++__i)1499    __vp_[__1d_[__i]] -= __v[__i];1500}1501 1502template <class _Tp>1503template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1504inline void mask_array<_Tp>::operator^=(const _Expr& __v) const {1505  size_t __n = __1d_.size();1506  for (size_t __i = 0; __i < __n; ++__i)1507    __vp_[__1d_[__i]] ^= __v[__i];1508}1509 1510template <class _Tp>1511template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1512inline void mask_array<_Tp>::operator&=(const _Expr& __v) const {1513  size_t __n = __1d_.size();1514  for (size_t __i = 0; __i < __n; ++__i)1515    __vp_[__1d_[__i]] &= __v[__i];1516}1517 1518template <class _Tp>1519template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1520inline void mask_array<_Tp>::operator|=(const _Expr& __v) const {1521  size_t __n = __1d_.size();1522  for (size_t __i = 0; __i < __n; ++__i)1523    __vp_[__1d_[__i]] |= __v[__i];1524}1525 1526template <class _Tp>1527template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1528inline void mask_array<_Tp>::operator<<=(const _Expr& __v) const {1529  size_t __n = __1d_.size();1530  for (size_t __i = 0; __i < __n; ++__i)1531    __vp_[__1d_[__i]] <<= __v[__i];1532}1533 1534template <class _Tp>1535template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1536inline void mask_array<_Tp>::operator>>=(const _Expr& __v) const {1537  size_t __n = __1d_.size();1538  for (size_t __i = 0; __i < __n; ++__i)1539    __vp_[__1d_[__i]] >>= __v[__i];1540}1541 1542template <class _Tp>1543inline const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const {1544  size_t __n = __1d_.size();1545  for (size_t __i = 0; __i < __n; ++__i)1546    __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];1547  return *this;1548}1549 1550template <class _Tp>1551inline void mask_array<_Tp>::operator=(const value_type& __x) const {1552  size_t __n = __1d_.size();1553  for (size_t __i = 0; __i < __n; ++__i)1554    __vp_[__1d_[__i]] = __x;1555}1556 1557template <class _ValExpr>1558class __mask_expr {1559  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;1560 1561public:1562  typedef typename _RmExpr::value_type value_type;1563  typedef value_type __result_type;1564 1565private:1566  _ValExpr __expr_;1567  valarray<size_t> __1d_;1568 1569  _LIBCPP_HIDE_FROM_ABI __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)1570      : __expr_(__e), __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) {1571    size_t __j = 0;1572    for (size_t __i = 0; __i < __vb.size(); ++__i)1573      if (__vb[__i])1574        __1d_[__j++] = __i;1575  }1576 1577public:1578  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }1579 1580  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); }1581 1582  template <class>1583  friend class __val_expr;1584  template <class>1585  friend class valarray;1586};1587 1588// indirect_array1589 1590template <class _Tp>1591class _LIBCPP_TEMPLATE_VIS indirect_array {1592public:1593  typedef _Tp value_type;1594 1595private:1596  value_type* __vp_;1597  valarray<size_t> __1d_;1598 1599public:1600  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1601  void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;1602 1603  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1604  void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;1605 1606  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1607  void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;1608 1609  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1610  void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;1611 1612  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1613  void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;1614 1615  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1616  void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;1617 1618  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1619  void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;1620 1621  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1622  void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;1623 1624  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1625  void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;1626 1627  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1628  void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;1629 1630  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1631  void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;1632 1633  indirect_array(const indirect_array&) = default;1634 1635  _LIBCPP_HIDE_FROM_ABI const indirect_array& operator=(const indirect_array& __ia) const;1636 1637  _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;1638 1639  // Behaves like __val_expr::operator[], which returns by value.1640  _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {1641    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "indirect_array.__get() index out of bounds");1642    return __vp_[__1d_[__i]];1643  }1644 1645private:1646  _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)1647      : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {}1648 1649  template <class>1650  friend class valarray;1651};1652 1653template <class _Tp>1654template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1655inline void indirect_array<_Tp>::operator=(const _Expr& __v) const {1656  size_t __n = __1d_.size();1657  for (size_t __i = 0; __i < __n; ++__i)1658    __vp_[__1d_[__i]] = __v[__i];1659}1660 1661template <class _Tp>1662template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1663inline void indirect_array<_Tp>::operator*=(const _Expr& __v) const {1664  size_t __n = __1d_.size();1665  for (size_t __i = 0; __i < __n; ++__i)1666    __vp_[__1d_[__i]] *= __v[__i];1667}1668 1669template <class _Tp>1670template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1671inline void indirect_array<_Tp>::operator/=(const _Expr& __v) const {1672  size_t __n = __1d_.size();1673  for (size_t __i = 0; __i < __n; ++__i)1674    __vp_[__1d_[__i]] /= __v[__i];1675}1676 1677template <class _Tp>1678template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1679inline void indirect_array<_Tp>::operator%=(const _Expr& __v) const {1680  size_t __n = __1d_.size();1681  for (size_t __i = 0; __i < __n; ++__i)1682    __vp_[__1d_[__i]] %= __v[__i];1683}1684 1685template <class _Tp>1686template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1687inline void indirect_array<_Tp>::operator+=(const _Expr& __v) const {1688  size_t __n = __1d_.size();1689  for (size_t __i = 0; __i < __n; ++__i)1690    __vp_[__1d_[__i]] += __v[__i];1691}1692 1693template <class _Tp>1694template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1695inline void indirect_array<_Tp>::operator-=(const _Expr& __v) const {1696  size_t __n = __1d_.size();1697  for (size_t __i = 0; __i < __n; ++__i)1698    __vp_[__1d_[__i]] -= __v[__i];1699}1700 1701template <class _Tp>1702template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1703inline void indirect_array<_Tp>::operator^=(const _Expr& __v) const {1704  size_t __n = __1d_.size();1705  for (size_t __i = 0; __i < __n; ++__i)1706    __vp_[__1d_[__i]] ^= __v[__i];1707}1708 1709template <class _Tp>1710template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1711inline void indirect_array<_Tp>::operator&=(const _Expr& __v) const {1712  size_t __n = __1d_.size();1713  for (size_t __i = 0; __i < __n; ++__i)1714    __vp_[__1d_[__i]] &= __v[__i];1715}1716 1717template <class _Tp>1718template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1719inline void indirect_array<_Tp>::operator|=(const _Expr& __v) const {1720  size_t __n = __1d_.size();1721  for (size_t __i = 0; __i < __n; ++__i)1722    __vp_[__1d_[__i]] |= __v[__i];1723}1724 1725template <class _Tp>1726template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1727inline void indirect_array<_Tp>::operator<<=(const _Expr& __v) const {1728  size_t __n = __1d_.size();1729  for (size_t __i = 0; __i < __n; ++__i)1730    __vp_[__1d_[__i]] <<= __v[__i];1731}1732 1733template <class _Tp>1734template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1735inline void indirect_array<_Tp>::operator>>=(const _Expr& __v) const {1736  size_t __n = __1d_.size();1737  for (size_t __i = 0; __i < __n; ++__i)1738    __vp_[__1d_[__i]] >>= __v[__i];1739}1740 1741template <class _Tp>1742inline const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const {1743  typedef const size_t* _Ip;1744  const value_type* __s = __ia.__vp_;1745  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; __i != __e; ++__i, ++__j)1746    __vp_[*__i] = __s[*__j];1747  return *this;1748}1749 1750template <class _Tp>1751inline void indirect_array<_Tp>::operator=(const value_type& __x) const {1752  typedef const size_t* _Ip;1753  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)1754    __vp_[*__i] = __x;1755}1756 1757template <class _ValExpr>1758class __indirect_expr {1759  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;1760 1761public:1762  typedef typename _RmExpr::value_type value_type;1763  typedef value_type __result_type;1764 1765private:1766  _ValExpr __expr_;1767  valarray<size_t> __1d_;1768 1769  _LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {}1770 1771public:1772  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }1773 1774  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); }1775 1776  template <class>1777  friend class __val_expr;1778  template <class>1779  friend class _LIBCPP_TEMPLATE_VIS valarray;1780};1781 1782template <class _ValExpr>1783class __val_expr {1784  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;1785 1786  _ValExpr __expr_;1787 1788public:1789  typedef typename _RmExpr::value_type value_type;1790  typedef typename _RmExpr::__result_type __result_type;1791 1792  _LIBCPP_HIDE_FROM_ABI explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}1793 1794  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__i]; }1795 1796  _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const {1797    typedef __slice_expr<_ValExpr> _NewExpr;1798    return __val_expr< _NewExpr >(_NewExpr(__s, __expr_));1799  }1800 1801  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const {1802    typedef __indirect_expr<_ValExpr> _NewExpr;1803    return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_));1804  }1805 1806  _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const {1807    typedef __mask_expr<_ValExpr> _NewExpr;1808    return __val_expr< _NewExpr >(_NewExpr(__vb, __expr_));1809  }1810 1811  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const {1812    typedef __indirect_expr<_ValExpr> _NewExpr;1813    return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_));1814  }1815 1816  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > operator+() const {1817    typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;1818    return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));1819  }1820 1821  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > operator-() const {1822    typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;1823    return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));1824  }1825 1826  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > operator~() const {1827    typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;1828    return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));1829  }1830 1831  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > operator!() const {1832    typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;1833    return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));1834  }1835 1836  operator valarray<__result_type>() const;1837 1838  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __expr_.size(); }1839 1840  _LIBCPP_HIDE_FROM_ABI __result_type sum() const {1841    size_t __n        = __expr_.size();1842    __result_type __r = __n ? __expr_[0] : __result_type();1843    for (size_t __i = 1; __i < __n; ++__i)1844      __r += __expr_[__i];1845    return __r;1846  }1847 1848  _LIBCPP_HIDE_FROM_ABI __result_type min() const {1849    size_t __n        = size();1850    __result_type __r = __n ? (*this)[0] : __result_type();1851    for (size_t __i = 1; __i < __n; ++__i) {1852      __result_type __x = __expr_[__i];1853      if (__x < __r)1854        __r = __x;1855    }1856    return __r;1857  }1858 1859  _LIBCPP_HIDE_FROM_ABI __result_type max() const {1860    size_t __n        = size();1861    __result_type __r = __n ? (*this)[0] : __result_type();1862    for (size_t __i = 1; __i < __n; ++__i) {1863      __result_type __x = __expr_[__i];1864      if (__r < __x)1865        __r = __x;1866    }1867    return __r;1868  }1869 1870  _LIBCPP_HIDE_FROM_ABI __val_expr<__shift_expr<_ValExpr> > shift(int __i) const {1871    return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));1872  }1873 1874  _LIBCPP_HIDE_FROM_ABI __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const {1875    return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));1876  }1877 1878  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(value_type)>, _ValExpr> >1879  apply(value_type __f(value_type)) const {1880    typedef __apply_expr<value_type, value_type (*)(value_type)> _Op;1881    typedef _UnaryOp<_Op, _ValExpr> _NewExpr;1882    return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));1883  }1884 1885  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(const value_type&)>, _ValExpr> >1886  apply(value_type __f(const value_type&)) const {1887    typedef __apply_expr<value_type, value_type (*)(const value_type&)> _Op;1888    typedef _UnaryOp<_Op, _ValExpr> _NewExpr;1889    return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));1890  }1891};1892 1893template <class _ValExpr>1894__val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const {1895  valarray<__result_type> __r;1896  size_t __n = __expr_.size();1897  if (__n) {1898    __r.__begin_ = __r.__end_ = allocator<__result_type>().allocate(__n);1899    for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)1900      ::new ((void*)__r.__end_) __result_type(__expr_[__i]);1901  }1902  return __r;1903}1904 1905// valarray1906 1907template <class _Tp>1908inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) {1909  if (__n) {1910    __begin_ = __end_ = allocator<value_type>().allocate(__n);1911#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1912    try {1913#endif // _LIBCPP_HAS_NO_EXCEPTIONS1914      for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)1915        ::new ((void*)__end_) value_type();1916#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1917    } catch (...) {1918      __clear(__n);1919      throw;1920    }1921#endif // _LIBCPP_HAS_NO_EXCEPTIONS1922  }1923}1924 1925template <class _Tp>1926inline valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(nullptr), __end_(nullptr) {1927  resize(__n, __x);1928}1929 1930template <class _Tp>1931valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) {1932  if (__n) {1933    __begin_ = __end_ = allocator<value_type>().allocate(__n);1934#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1935    try {1936#endif // _LIBCPP_HAS_NO_EXCEPTIONS1937      for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)1938        ::new ((void*)__end_) value_type(*__p);1939#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1940    } catch (...) {1941      __clear(__n);1942      throw;1943    }1944#endif // _LIBCPP_HAS_NO_EXCEPTIONS1945  }1946}1947 1948template <class _Tp>1949valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) {1950  if (__v.size()) {1951    __begin_ = __end_ = allocator<value_type>().allocate(__v.size());1952#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1953    try {1954#endif // _LIBCPP_HAS_NO_EXCEPTIONS1955      for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)1956        ::new ((void*)__end_) value_type(*__p);1957#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1958    } catch (...) {1959      __clear(__v.size());1960      throw;1961    }1962#endif // _LIBCPP_HAS_NO_EXCEPTIONS1963  }1964}1965 1966template <class _Tp>1967valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) {1968  const size_t __n = __sa.__size_;1969  if (__n) {1970    __begin_ = __end_ = allocator<value_type>().allocate(__n);1971#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1972    try {1973#endif // _LIBCPP_HAS_NO_EXCEPTIONS1974      size_t __n_left = __n;1975      for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)1976        ::new ((void*)__end_) value_type(*__p);1977#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1978    } catch (...) {1979      __clear(__n);1980      throw;1981    }1982#endif // _LIBCPP_HAS_NO_EXCEPTIONS1983  }1984}1985 1986template <class _Tp>1987valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr), __end_(nullptr) {1988  const size_t __n = __ga.__1d_.size();1989  if (__n) {1990    __begin_ = __end_ = allocator<value_type>().allocate(__n);1991#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1992    try {1993#endif // _LIBCPP_HAS_NO_EXCEPTIONS1994      typedef const size_t* _Ip;1995      const value_type* __s = __ga.__vp_;1996      for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_)1997        ::new ((void*)__end_) value_type(__s[*__i]);1998#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1999    } catch (...) {2000      __clear(__n);2001      throw;2002    }2003#endif // _LIBCPP_HAS_NO_EXCEPTIONS2004  }2005}2006 2007template <class _Tp>2008valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), __end_(nullptr) {2009  const size_t __n = __ma.__1d_.size();2010  if (__n) {2011    __begin_ = __end_ = allocator<value_type>().allocate(__n);2012#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2013    try {2014#endif // _LIBCPP_HAS_NO_EXCEPTIONS2015      typedef const size_t* _Ip;2016      const value_type* __s = __ma.__vp_;2017      for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_)2018        ::new ((void*)__end_) value_type(__s[*__i]);2019#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2020    } catch (...) {2021      __clear(__n);2022      throw;2023    }2024#endif // _LIBCPP_HAS_NO_EXCEPTIONS2025  }2026}2027 2028template <class _Tp>2029valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullptr), __end_(nullptr) {2030  const size_t __n = __ia.__1d_.size();2031  if (__n) {2032    __begin_ = __end_ = allocator<value_type>().allocate(__n);2033#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2034    try {2035#endif // _LIBCPP_HAS_NO_EXCEPTIONS2036      typedef const size_t* _Ip;2037      const value_type* __s = __ia.__vp_;2038      for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_)2039        ::new ((void*)__end_) value_type(__s[*__i]);2040#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2041    } catch (...) {2042      __clear(__n);2043      throw;2044    }2045#endif // _LIBCPP_HAS_NO_EXCEPTIONS2046  }2047}2048 2049template <class _Tp>2050inline valarray<_Tp>::~valarray() {2051  __clear(size());2052}2053 2054template <class _Tp>2055valarray<_Tp>& valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) {2056  size_t __n = __l - __f;2057  if (size() != __n) {2058    __clear(size());2059    __begin_ = allocator<value_type>().allocate(__n);2060    __end_   = __begin_ + __n;2061    std::uninitialized_copy(__f, __l, __begin_);2062  } else {2063    std::copy(__f, __l, __begin_);2064  }2065  return *this;2066}2067 2068template <class _Tp>2069valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) {2070  if (this != std::addressof(__v))2071    return __assign_range(__v.__begin_, __v.__end_);2072  return *this;2073}2074 2075template <class _Tp>2076inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) {2077  std::fill(__begin_, __end_, __x);2078  return *this;2079}2080 2081template <class _Tp>2082inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<value_type>& __sa) {2083  value_type* __t       = __begin_;2084  const value_type* __s = __sa.__vp_;2085  for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)2086    *__t = *__s;2087  return *this;2088}2089 2090template <class _Tp>2091inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) {2092  typedef const size_t* _Ip;2093  value_type* __t       = __begin_;2094  const value_type* __s = __ga.__vp_;2095  for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__t)2096    *__t = __s[*__i];2097  return *this;2098}2099 2100template <class _Tp>2101inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<value_type>& __ma) {2102  typedef const size_t* _Ip;2103  value_type* __t       = __begin_;2104  const value_type* __s = __ma.__vp_;2105  for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__t)2106    *__t = __s[*__i];2107  return *this;2108}2109 2110template <class _Tp>2111inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) {2112  typedef const size_t* _Ip;2113  value_type* __t       = __begin_;2114  const value_type* __s = __ia.__vp_;2115  for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__t)2116    *__t = __s[*__i];2117  return *this;2118}2119 2120template <class _Tp>2121template <class _ValExpr>2122inline valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) {2123  size_t __n = __v.size();2124  if (size() != __n)2125    resize(__n);2126  value_type* __t = __begin_;2127  for (size_t __i = 0; __i != __n; ++__t, ++__i)2128    *__t = __result_type(__v[__i]);2129  return *this;2130}2131 2132template <class _Tp>2133inline __val_expr<__slice_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](slice __s) const {2134  return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));2135}2136 2137template <class _Tp>2138inline slice_array<_Tp> valarray<_Tp>::operator[](slice __s) {2139  return slice_array<value_type>(__s, *this);2140}2141 2142template <class _Tp>2143inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const gslice& __gs) const {2144  return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));2145}2146 2147template <class _Tp>2148inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) {2149  return gslice_array<value_type>(__gs, *this);2150}2151 2152template <class _Tp>2153inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const {2154  return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));2155}2156 2157template <class _Tp>2158inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) {2159  return mask_array<value_type>(__vb, *this);2160}2161 2162template <class _Tp>2163inline __val_expr<__indirect_expr<const valarray<_Tp>&> >2164valarray<_Tp>::operator[](const valarray<size_t>& __vs) const {2165  return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));2166}2167 2168template <class _Tp>2169inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __vs) {2170  return indirect_array<value_type>(__vs, *this);2171}2172 2173template <class _Tp>2174inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const {2175  using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>;2176  return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this));2177}2178 2179template <class _Tp>2180inline __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator-() const {2181  using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>;2182  return __val_expr<_Op>(_Op(negate<_Tp>(), *this));2183}2184 2185template <class _Tp>2186inline __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator~() const {2187  using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>;2188  return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this));2189}2190 2191template <class _Tp>2192inline __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator!() const {2193  using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>;2194  return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this));2195}2196 2197template <class _Tp>2198inline valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) {2199  for (value_type* __p = __begin_; __p != __end_; ++__p)2200    *__p *= __x;2201  return *this;2202}2203 2204template <class _Tp>2205inline valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) {2206  for (value_type* __p = __begin_; __p != __end_; ++__p)2207    *__p /= __x;2208  return *this;2209}2210 2211template <class _Tp>2212inline valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) {2213  for (value_type* __p = __begin_; __p != __end_; ++__p)2214    *__p %= __x;2215  return *this;2216}2217 2218template <class _Tp>2219inline valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) {2220  for (value_type* __p = __begin_; __p != __end_; ++__p)2221    *__p += __x;2222  return *this;2223}2224 2225template <class _Tp>2226inline valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) {2227  for (value_type* __p = __begin_; __p != __end_; ++__p)2228    *__p -= __x;2229  return *this;2230}2231 2232template <class _Tp>2233inline valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) {2234  for (value_type* __p = __begin_; __p != __end_; ++__p)2235    *__p ^= __x;2236  return *this;2237}2238 2239template <class _Tp>2240inline valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) {2241  for (value_type* __p = __begin_; __p != __end_; ++__p)2242    *__p &= __x;2243  return *this;2244}2245 2246template <class _Tp>2247inline valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) {2248  for (value_type* __p = __begin_; __p != __end_; ++__p)2249    *__p |= __x;2250  return *this;2251}2252 2253template <class _Tp>2254inline valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) {2255  for (value_type* __p = __begin_; __p != __end_; ++__p)2256    *__p <<= __x;2257  return *this;2258}2259 2260template <class _Tp>2261inline valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) {2262  for (value_type* __p = __begin_; __p != __end_; ++__p)2263    *__p >>= __x;2264  return *this;2265}2266 2267template <class _Tp>2268template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2269inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) {2270  size_t __i = 0;2271  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2272    *__t *= std::__get(__v, __i);2273  return *this;2274}2275 2276template <class _Tp>2277template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2278inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) {2279  size_t __i = 0;2280  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2281    *__t /= std::__get(__v, __i);2282  return *this;2283}2284 2285template <class _Tp>2286template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2287inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) {2288  size_t __i = 0;2289  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2290    *__t %= std::__get(__v, __i);2291  return *this;2292}2293 2294template <class _Tp>2295template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2296inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) {2297  size_t __i = 0;2298  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2299    *__t += std::__get(__v, __i);2300  return *this;2301}2302 2303template <class _Tp>2304template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2305inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) {2306  size_t __i = 0;2307  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2308    *__t -= std::__get(__v, __i);2309  return *this;2310}2311 2312template <class _Tp>2313template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2314inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) {2315  size_t __i = 0;2316  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2317    *__t ^= std::__get(__v, __i);2318  return *this;2319}2320 2321template <class _Tp>2322template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2323inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) {2324  size_t __i = 0;2325  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2326    *__t |= std::__get(__v, __i);2327  return *this;2328}2329 2330template <class _Tp>2331template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2332inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) {2333  size_t __i = 0;2334  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2335    *__t &= std::__get(__v, __i);2336  return *this;2337}2338 2339template <class _Tp>2340template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2341inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) {2342  size_t __i = 0;2343  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2344    *__t <<= std::__get(__v, __i);2345  return *this;2346}2347 2348template <class _Tp>2349template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2350inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) {2351  size_t __i = 0;2352  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2353    *__t >>= std::__get(__v, __i);2354  return *this;2355}2356 2357template <class _Tp>2358inline void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT {2359  std::swap(__begin_, __v.__begin_);2360  std::swap(__end_, __v.__end_);2361}2362 2363template <class _Tp>2364inline _Tp valarray<_Tp>::sum() const {2365  if (__begin_ == __end_)2366    return value_type();2367  const value_type* __p = __begin_;2368  _Tp __r               = *__p;2369  for (++__p; __p != __end_; ++__p)2370    __r += *__p;2371  return __r;2372}2373 2374template <class _Tp>2375inline _Tp valarray<_Tp>::min() const {2376  if (__begin_ == __end_)2377    return value_type();2378  return *std::min_element(__begin_, __end_);2379}2380 2381template <class _Tp>2382inline _Tp valarray<_Tp>::max() const {2383  if (__begin_ == __end_)2384    return value_type();2385  return *std::max_element(__begin_, __end_);2386}2387 2388template <class _Tp>2389valarray<_Tp> valarray<_Tp>::shift(int __i) const {2390  valarray<value_type> __r;2391  size_t __n = size();2392  if (__n) {2393    __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);2394    const value_type* __sb;2395    value_type* __tb;2396    value_type* __te;2397    if (__i >= 0) {2398      __i  = std::min(__i, static_cast<int>(__n));2399      __sb = __begin_ + __i;2400      __tb = __r.__begin_;2401      __te = __r.__begin_ + (__n - __i);2402    } else {2403      __i  = std::min(-__i, static_cast<int>(__n));2404      __sb = __begin_;2405      __tb = __r.__begin_ + __i;2406      __te = __r.__begin_ + __n;2407    }2408    for (; __r.__end_ != __tb; ++__r.__end_)2409      ::new ((void*)__r.__end_) value_type();2410    for (; __r.__end_ != __te; ++__r.__end_, ++__sb)2411      ::new ((void*)__r.__end_) value_type(*__sb);2412    for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)2413      ::new ((void*)__r.__end_) value_type();2414  }2415  return __r;2416}2417 2418template <class _Tp>2419valarray<_Tp> valarray<_Tp>::cshift(int __i) const {2420  valarray<value_type> __r;2421  size_t __n = size();2422  if (__n) {2423    __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);2424    __i %= static_cast<int>(__n);2425    const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;2426    for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)2427      ::new ((void*)__r.__end_) value_type(*__s);2428    for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)2429      ::new ((void*)__r.__end_) value_type(*__s);2430  }2431  return __r;2432}2433 2434template <class _Tp>2435valarray<_Tp> valarray<_Tp>::apply(value_type __f(value_type)) const {2436  valarray<value_type> __r;2437  size_t __n = size();2438  if (__n) {2439    __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);2440    for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)2441      ::new ((void*)__r.__end_) value_type(__f(*__p));2442  }2443  return __r;2444}2445 2446template <class _Tp>2447valarray<_Tp> valarray<_Tp>::apply(value_type __f(const value_type&)) const {2448  valarray<value_type> __r;2449  size_t __n = size();2450  if (__n) {2451    __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);2452    for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)2453      ::new ((void*)__r.__end_) value_type(__f(*__p));2454  }2455  return __r;2456}2457 2458template <class _Tp>2459inline void valarray<_Tp>::__clear(size_t __capacity) {2460  if (__begin_ != nullptr) {2461    while (__end_ != __begin_)2462      (--__end_)->~value_type();2463    allocator<value_type>().deallocate(__begin_, __capacity);2464    __begin_ = __end_ = nullptr;2465  }2466}2467 2468template <class _Tp>2469void valarray<_Tp>::resize(size_t __n, value_type __x) {2470  __clear(size());2471  if (__n) {2472    __begin_ = __end_ = allocator<value_type>().allocate(__n);2473#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2474    try {2475#endif // _LIBCPP_HAS_NO_EXCEPTIONS2476      for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)2477        ::new ((void*)__end_) value_type(__x);2478#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2479    } catch (...) {2480      __clear(__n);2481      throw;2482    }2483#endif // _LIBCPP_HAS_NO_EXCEPTIONS2484  }2485}2486 2487template <class _Tp>2488inline _LIBCPP_HIDE_FROM_ABI void swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT {2489  __x.swap(__y);2490}2491 2492template <class _Expr1,2493          class _Expr2,2494          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2495inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >2496operator*(const _Expr1& __x, const _Expr2& __y) {2497  typedef typename _Expr1::value_type value_type;2498  typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;2499  return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));2500}2501 2502template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2503inline _LIBCPP_HIDE_FROM_ABI2504__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2505operator*(const _Expr& __x, const typename _Expr::value_type& __y) {2506  typedef typename _Expr::value_type value_type;2507  typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;2508  return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2509}2510 2511template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2512inline _LIBCPP_HIDE_FROM_ABI2513__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2514operator*(const typename _Expr::value_type& __x, const _Expr& __y) {2515  typedef typename _Expr::value_type value_type;2516  typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;2517  return __val_expr<_Op>(_Op(multiplies<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2518}2519 2520template <class _Expr1,2521          class _Expr2,2522          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2523inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >2524operator/(const _Expr1& __x, const _Expr2& __y) {2525  typedef typename _Expr1::value_type value_type;2526  typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;2527  return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));2528}2529 2530template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2531inline _LIBCPP_HIDE_FROM_ABI2532__val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2533operator/(const _Expr& __x, const typename _Expr::value_type& __y) {2534  typedef typename _Expr::value_type value_type;2535  typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;2536  return __val_expr<_Op>(_Op(divides<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2537}2538 2539template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2540inline _LIBCPP_HIDE_FROM_ABI2541__val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2542operator/(const typename _Expr::value_type& __x, const _Expr& __y) {2543  typedef typename _Expr::value_type value_type;2544  typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;2545  return __val_expr<_Op>(_Op(divides<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2546}2547 2548template <class _Expr1,2549          class _Expr2,2550          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2551inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >2552operator%(const _Expr1& __x, const _Expr2& __y) {2553  typedef typename _Expr1::value_type value_type;2554  typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;2555  return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));2556}2557 2558template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2559inline _LIBCPP_HIDE_FROM_ABI2560__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2561operator%(const _Expr& __x, const typename _Expr::value_type& __y) {2562  typedef typename _Expr::value_type value_type;2563  typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;2564  return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2565}2566 2567template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2568inline _LIBCPP_HIDE_FROM_ABI2569__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2570operator%(const typename _Expr::value_type& __x, const _Expr& __y) {2571  typedef typename _Expr::value_type value_type;2572  typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;2573  return __val_expr<_Op>(_Op(modulus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2574}2575 2576template <class _Expr1,2577          class _Expr2,2578          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2579inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >2580operator+(const _Expr1& __x, const _Expr2& __y) {2581  typedef typename _Expr1::value_type value_type;2582  typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;2583  return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));2584}2585 2586template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2587inline _LIBCPP_HIDE_FROM_ABI2588__val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2589operator+(const _Expr& __x, const typename _Expr::value_type& __y) {2590  typedef typename _Expr::value_type value_type;2591  typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;2592  return __val_expr<_Op>(_Op(plus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2593}2594 2595template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2596inline _LIBCPP_HIDE_FROM_ABI2597__val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2598operator+(const typename _Expr::value_type& __x, const _Expr& __y) {2599  typedef typename _Expr::value_type value_type;2600  typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;2601  return __val_expr<_Op>(_Op(plus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2602}2603 2604template <class _Expr1,2605          class _Expr2,2606          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2607inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >2608operator-(const _Expr1& __x, const _Expr2& __y) {2609  typedef typename _Expr1::value_type value_type;2610  typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;2611  return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));2612}2613 2614template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2615inline _LIBCPP_HIDE_FROM_ABI2616__val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2617operator-(const _Expr& __x, const typename _Expr::value_type& __y) {2618  typedef typename _Expr::value_type value_type;2619  typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;2620  return __val_expr<_Op>(_Op(minus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2621}2622 2623template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2624inline _LIBCPP_HIDE_FROM_ABI2625__val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2626operator-(const typename _Expr::value_type& __x, const _Expr& __y) {2627  typedef typename _Expr::value_type value_type;2628  typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;2629  return __val_expr<_Op>(_Op(minus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2630}2631 2632template <class _Expr1,2633          class _Expr2,2634          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2635inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >2636operator^(const _Expr1& __x, const _Expr2& __y) {2637  typedef typename _Expr1::value_type value_type;2638  typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;2639  return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));2640}2641 2642template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2643inline _LIBCPP_HIDE_FROM_ABI2644__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2645operator^(const _Expr& __x, const typename _Expr::value_type& __y) {2646  typedef typename _Expr::value_type value_type;2647  typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;2648  return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2649}2650 2651template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2652inline _LIBCPP_HIDE_FROM_ABI2653__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2654operator^(const typename _Expr::value_type& __x, const _Expr& __y) {2655  typedef typename _Expr::value_type value_type;2656  typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;2657  return __val_expr<_Op>(_Op(bit_xor<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2658}2659 2660template <class _Expr1,2661          class _Expr2,2662          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2663inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >2664operator&(const _Expr1& __x, const _Expr2& __y) {2665  typedef typename _Expr1::value_type value_type;2666  typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;2667  return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));2668}2669 2670template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2671inline _LIBCPP_HIDE_FROM_ABI2672__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2673operator&(const _Expr& __x, const typename _Expr::value_type& __y) {2674  typedef typename _Expr::value_type value_type;2675  typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;2676  return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2677}2678 2679template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2680inline _LIBCPP_HIDE_FROM_ABI2681__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2682operator&(const typename _Expr::value_type& __x, const _Expr& __y) {2683  typedef typename _Expr::value_type value_type;2684  typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;2685  return __val_expr<_Op>(_Op(bit_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2686}2687 2688template <class _Expr1,2689          class _Expr2,2690          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2691inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >2692operator|(const _Expr1& __x, const _Expr2& __y) {2693  typedef typename _Expr1::value_type value_type;2694  typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;2695  return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));2696}2697 2698template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2699inline _LIBCPP_HIDE_FROM_ABI2700__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2701operator|(const _Expr& __x, const typename _Expr::value_type& __y) {2702  typedef typename _Expr::value_type value_type;2703  typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;2704  return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2705}2706 2707template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2708inline _LIBCPP_HIDE_FROM_ABI2709__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2710operator|(const typename _Expr::value_type& __x, const _Expr& __y) {2711  typedef typename _Expr::value_type value_type;2712  typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;2713  return __val_expr<_Op>(_Op(bit_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2714}2715 2716template <class _Expr1,2717          class _Expr2,2718          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2719inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >2720operator<<(const _Expr1& __x, const _Expr2& __y) {2721  typedef typename _Expr1::value_type value_type;2722  typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;2723  return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));2724}2725 2726template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2727inline _LIBCPP_HIDE_FROM_ABI2728__val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2729operator<<(const _Expr& __x, const typename _Expr::value_type& __y) {2730  typedef typename _Expr::value_type value_type;2731  typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;2732  return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2733}2734 2735template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2736inline _LIBCPP_HIDE_FROM_ABI2737__val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2738operator<<(const typename _Expr::value_type& __x, const _Expr& __y) {2739  typedef typename _Expr::value_type value_type;2740  typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;2741  return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2742}2743 2744template <class _Expr1,2745          class _Expr2,2746          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2747inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >2748operator>>(const _Expr1& __x, const _Expr2& __y) {2749  typedef typename _Expr1::value_type value_type;2750  typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;2751  return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));2752}2753 2754template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2755inline _LIBCPP_HIDE_FROM_ABI __val_expr<2756    _BinaryOp<__bit_shift_right<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2757operator>>(const _Expr& __x, const typename _Expr::value_type& __y) {2758  typedef typename _Expr::value_type value_type;2759  typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;2760  return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2761}2762 2763template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2764inline _LIBCPP_HIDE_FROM_ABI2765__val_expr< _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2766operator>>(const typename _Expr::value_type& __x, const _Expr& __y) {2767  typedef typename _Expr::value_type value_type;2768  typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;2769  return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2770}2771 2772template <class _Expr1,2773          class _Expr2,2774          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2775inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >2776operator&&(const _Expr1& __x, const _Expr2& __y) {2777  typedef typename _Expr1::value_type value_type;2778  typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;2779  return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));2780}2781 2782template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2783inline _LIBCPP_HIDE_FROM_ABI2784__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2785operator&&(const _Expr& __x, const typename _Expr::value_type& __y) {2786  typedef typename _Expr::value_type value_type;2787  typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;2788  return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2789}2790 2791template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2792inline _LIBCPP_HIDE_FROM_ABI2793__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2794operator&&(const typename _Expr::value_type& __x, const _Expr& __y) {2795  typedef typename _Expr::value_type value_type;2796  typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;2797  return __val_expr<_Op>(_Op(logical_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2798}2799 2800template <class _Expr1,2801          class _Expr2,2802          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2803inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >2804operator||(const _Expr1& __x, const _Expr2& __y) {2805  typedef typename _Expr1::value_type value_type;2806  typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;2807  return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));2808}2809 2810template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2811inline _LIBCPP_HIDE_FROM_ABI2812__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2813operator||(const _Expr& __x, const typename _Expr::value_type& __y) {2814  typedef typename _Expr::value_type value_type;2815  typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;2816  return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2817}2818 2819template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2820inline _LIBCPP_HIDE_FROM_ABI2821__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2822operator||(const typename _Expr::value_type& __x, const _Expr& __y) {2823  typedef typename _Expr::value_type value_type;2824  typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;2825  return __val_expr<_Op>(_Op(logical_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2826}2827 2828template <class _Expr1,2829          class _Expr2,2830          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2831inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >2832operator==(const _Expr1& __x, const _Expr2& __y) {2833  typedef typename _Expr1::value_type value_type;2834  typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;2835  return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));2836}2837 2838template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2839inline _LIBCPP_HIDE_FROM_ABI2840__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2841operator==(const _Expr& __x, const typename _Expr::value_type& __y) {2842  typedef typename _Expr::value_type value_type;2843  typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;2844  return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2845}2846 2847template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2848inline _LIBCPP_HIDE_FROM_ABI2849__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2850operator==(const typename _Expr::value_type& __x, const _Expr& __y) {2851  typedef typename _Expr::value_type value_type;2852  typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;2853  return __val_expr<_Op>(_Op(equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2854}2855 2856template <class _Expr1,2857          class _Expr2,2858          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2859inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >2860operator!=(const _Expr1& __x, const _Expr2& __y) {2861  typedef typename _Expr1::value_type value_type;2862  typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;2863  return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));2864}2865 2866template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2867inline _LIBCPP_HIDE_FROM_ABI2868__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2869operator!=(const _Expr& __x, const typename _Expr::value_type& __y) {2870  typedef typename _Expr::value_type value_type;2871  typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;2872  return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2873}2874 2875template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2876inline _LIBCPP_HIDE_FROM_ABI2877__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2878operator!=(const typename _Expr::value_type& __x, const _Expr& __y) {2879  typedef typename _Expr::value_type value_type;2880  typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;2881  return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2882}2883 2884template <class _Expr1,2885          class _Expr2,2886          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2887inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >2888operator<(const _Expr1& __x, const _Expr2& __y) {2889  typedef typename _Expr1::value_type value_type;2890  typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;2891  return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));2892}2893 2894template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2895inline _LIBCPP_HIDE_FROM_ABI2896__val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2897operator<(const _Expr& __x, const typename _Expr::value_type& __y) {2898  typedef typename _Expr::value_type value_type;2899  typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;2900  return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2901}2902 2903template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2904inline _LIBCPP_HIDE_FROM_ABI2905__val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2906operator<(const typename _Expr::value_type& __x, const _Expr& __y) {2907  typedef typename _Expr::value_type value_type;2908  typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;2909  return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2910}2911 2912template <class _Expr1,2913          class _Expr2,2914          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2915inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >2916operator>(const _Expr1& __x, const _Expr2& __y) {2917  typedef typename _Expr1::value_type value_type;2918  typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;2919  return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));2920}2921 2922template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2923inline _LIBCPP_HIDE_FROM_ABI2924__val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2925operator>(const _Expr& __x, const typename _Expr::value_type& __y) {2926  typedef typename _Expr::value_type value_type;2927  typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;2928  return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2929}2930 2931template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2932inline _LIBCPP_HIDE_FROM_ABI2933__val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2934operator>(const typename _Expr::value_type& __x, const _Expr& __y) {2935  typedef typename _Expr::value_type value_type;2936  typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;2937  return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2938}2939 2940template <class _Expr1,2941          class _Expr2,2942          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2943inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >2944operator<=(const _Expr1& __x, const _Expr2& __y) {2945  typedef typename _Expr1::value_type value_type;2946  typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;2947  return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));2948}2949 2950template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2951inline _LIBCPP_HIDE_FROM_ABI2952__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2953operator<=(const _Expr& __x, const typename _Expr::value_type& __y) {2954  typedef typename _Expr::value_type value_type;2955  typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;2956  return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2957}2958 2959template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2960inline _LIBCPP_HIDE_FROM_ABI2961__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2962operator<=(const typename _Expr::value_type& __x, const _Expr& __y) {2963  typedef typename _Expr::value_type value_type;2964  typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;2965  return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2966}2967 2968template <class _Expr1,2969          class _Expr2,2970          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2971inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >2972operator>=(const _Expr1& __x, const _Expr2& __y) {2973  typedef typename _Expr1::value_type value_type;2974  typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;2975  return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));2976}2977 2978template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2979inline _LIBCPP_HIDE_FROM_ABI2980__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >2981operator>=(const _Expr& __x, const typename _Expr::value_type& __y) {2982  typedef typename _Expr::value_type value_type;2983  typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;2984  return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));2985}2986 2987template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2988inline _LIBCPP_HIDE_FROM_ABI2989__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >2990operator>=(const typename _Expr::value_type& __x, const _Expr& __y) {2991  typedef typename _Expr::value_type value_type;2992  typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;2993  return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2994}2995 2996template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2997inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >2998abs(const _Expr& __x) {2999  typedef typename _Expr::value_type value_type;3000  typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;3001  return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));3002}3003 3004template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3005inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >3006acos(const _Expr& __x) {3007  typedef typename _Expr::value_type value_type;3008  typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;3009  return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));3010}3011 3012template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3013inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >3014asin(const _Expr& __x) {3015  typedef typename _Expr::value_type value_type;3016  typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;3017  return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));3018}3019 3020template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3021inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >3022atan(const _Expr& __x) {3023  typedef typename _Expr::value_type value_type;3024  typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;3025  return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));3026}3027 3028template <class _Expr1,3029          class _Expr2,3030          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>3031inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >3032atan2(const _Expr1& __x, const _Expr2& __y) {3033  typedef typename _Expr1::value_type value_type;3034  typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;3035  return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));3036}3037 3038template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3039inline _LIBCPP_HIDE_FROM_ABI3040__val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >3041atan2(const _Expr& __x, const typename _Expr::value_type& __y) {3042  typedef typename _Expr::value_type value_type;3043  typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;3044  return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));3045}3046 3047template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3048inline _LIBCPP_HIDE_FROM_ABI3049__val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >3050atan2(const typename _Expr::value_type& __x, const _Expr& __y) {3051  typedef typename _Expr::value_type value_type;3052  typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;3053  return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));3054}3055 3056template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3057inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >3058cos(const _Expr& __x) {3059  typedef typename _Expr::value_type value_type;3060  typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;3061  return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));3062}3063 3064template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3065inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >3066cosh(const _Expr& __x) {3067  typedef typename _Expr::value_type value_type;3068  typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;3069  return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));3070}3071 3072template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3073inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >3074exp(const _Expr& __x) {3075  typedef typename _Expr::value_type value_type;3076  typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;3077  return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));3078}3079 3080template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3081inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >3082log(const _Expr& __x) {3083  typedef typename _Expr::value_type value_type;3084  typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;3085  return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));3086}3087 3088template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3089inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >3090log10(const _Expr& __x) {3091  typedef typename _Expr::value_type value_type;3092  typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;3093  return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));3094}3095 3096template <class _Expr1,3097          class _Expr2,3098          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>3099inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >3100pow(const _Expr1& __x, const _Expr2& __y) {3101  typedef typename _Expr1::value_type value_type;3102  typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;3103  return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));3104}3105 3106template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3107inline _LIBCPP_HIDE_FROM_ABI3108__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >3109pow(const _Expr& __x, const typename _Expr::value_type& __y) {3110  typedef typename _Expr::value_type value_type;3111  typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;3112  return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));3113}3114 3115template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3116inline _LIBCPP_HIDE_FROM_ABI3117__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >3118pow(const typename _Expr::value_type& __x, const _Expr& __y) {3119  typedef typename _Expr::value_type value_type;3120  typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;3121  return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));3122}3123 3124template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3125inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >3126sin(const _Expr& __x) {3127  typedef typename _Expr::value_type value_type;3128  typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;3129  return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));3130}3131 3132template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3133inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >3134sinh(const _Expr& __x) {3135  typedef typename _Expr::value_type value_type;3136  typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;3137  return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));3138}3139 3140template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3141inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >3142sqrt(const _Expr& __x) {3143  typedef typename _Expr::value_type value_type;3144  typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;3145  return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));3146}3147 3148template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3149inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >3150tan(const _Expr& __x) {3151  typedef typename _Expr::value_type value_type;3152  typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;3153  return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));3154}3155 3156template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3157inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >3158tanh(const _Expr& __x) {3159  typedef typename _Expr::value_type value_type;3160  typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;3161  return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));3162}3163 3164template <class _Tp>3165inline _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v) {3166  return __v.__begin_;3167}3168 3169template <class _Tp>3170inline _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v) {3171  return __v.__begin_;3172}3173 3174template <class _Tp>3175inline _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v) {3176  return __v.__end_;3177}3178 3179template <class _Tp>3180inline _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v) {3181  return __v.__end_;3182}3183 3184_LIBCPP_END_NAMESPACE_STD3185 3186_LIBCPP_POP_MACROS3187 3188#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)3189#  include <__cxx03/algorithm>3190#  include <__cxx03/cstdlib>3191#  include <__cxx03/cstring>3192#  include <__cxx03/functional>3193#  include <__cxx03/stdexcept>3194#  include <__cxx03/type_traits>3195#endif3196 3197#endif // _LIBCPP___CXX03_VALARRAY3198