brintos

brintos / llvm-project-archived public Read only

0
0
Text · 123.2 KiB · 215811d Raw
3312 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_VALARRAY11#define _LIBCPP_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#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)347#  include <__cxx03/valarray>348#else349#  include <__algorithm/copy.h>350#  include <__algorithm/count.h>351#  include <__algorithm/fill.h>352#  include <__algorithm/max_element.h>353#  include <__algorithm/min.h>354#  include <__algorithm/min_element.h>355#  include <__algorithm/unwrap_iter.h>356#  include <__assert>357#  include <__config>358#  include <__cstddef/ptrdiff_t.h>359#  include <__functional/operations.h>360#  include <__memory/addressof.h>361#  include <__memory/allocator.h>362#  include <__memory/uninitialized_algorithms.h>363#  include <__type_traits/decay.h>364#  include <__type_traits/remove_reference.h>365#  include <__utility/exception_guard.h>366#  include <__utility/move.h>367#  include <__utility/swap.h>368#  include <cmath>369#  include <version>370 371// standard-mandated includes372 373// [valarray.syn]374#  include <initializer_list>375 376#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)377#    pragma GCC system_header378#  endif379 380_LIBCPP_PUSH_MACROS381#  include <__undef_macros>382 383_LIBCPP_BEGIN_NAMESPACE_STD384 385template <class _Tp>386class valarray;387 388class slice {389  size_t __start_;390  size_t __size_;391  size_t __stride_;392 393public:394  _LIBCPP_HIDE_FROM_ABI slice() : __start_(0), __size_(0), __stride_(0) {}395 396  _LIBCPP_HIDE_FROM_ABI slice(size_t __start, size_t __size, size_t __stride)397      : __start_(__start), __size_(__size), __stride_(__stride) {}398 399  _LIBCPP_HIDE_FROM_ABI size_t start() const { return __start_; }400  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }401  _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; }402 403#  if _LIBCPP_STD_VER >= 20404 405  _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) {406    return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride();407  }408 409#  endif410};411 412template <class _Tp>413class slice_array;414class _LIBCPP_EXPORTED_FROM_ABI gslice;415template <class _Tp>416class gslice_array;417template <class _Tp>418class mask_array;419template <class _Tp>420class indirect_array;421 422template <class _Tp>423_LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v);424 425template <class _Tp>426_LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v);427 428template <class _Tp>429_LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v);430 431template <class _Tp>432_LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v);433 434template <class _Op, class _A0>435struct _UnaryOp {436  typedef typename _Op::__result_type __result_type;437  using value_type = __decay_t<__result_type>;438 439  _Op __op_;440  _A0 __a0_;441 442  _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}443 444  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); }445 446  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }447};448 449template <class _Op, class _A0, class _A1>450struct _BinaryOp {451  typedef typename _Op::__result_type __result_type;452  using value_type = __decay_t<__result_type>;453 454  _Op __op_;455  _A0 __a0_;456  _A1 __a1_;457 458  _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)459      : __op_(__op), __a0_(__a0), __a1_(__a1) {}460 461  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }462 463  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }464};465 466template <class _Tp>467class __scalar_expr {468public:469  typedef _Tp value_type;470  typedef const _Tp& __result_type;471 472private:473  const value_type& __t_;474  size_t __s_;475 476public:477  _LIBCPP_HIDE_FROM_ABI explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}478 479  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t) const { return __t_; }480 481  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __s_; }482};483 484template <class _Tp>485struct __unary_plus {486  typedef _Tp __result_type;487  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return +__x; }488};489 490template <class _Tp>491struct __bit_not {492  typedef _Tp __result_type;493  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }494};495 496template <class _Tp>497struct __bit_shift_left {498  typedef _Tp __result_type;499  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x << __y; }500};501 502template <class _Tp>503struct __bit_shift_right {504  typedef _Tp __result_type;505  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x >> __y; }506};507 508template <class _Tp, class _Fp>509struct __apply_expr {510private:511  _Fp __f_;512 513public:514  typedef _Tp __result_type;515 516  _LIBCPP_HIDE_FROM_ABI explicit __apply_expr(_Fp __f) : __f_(__f) {}517 518  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return __f_(__x); }519};520 521template <class _Tp>522struct __abs_expr {523  typedef _Tp __result_type;524  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::abs(__x); }525};526 527template <class _Tp>528struct __acos_expr {529  typedef _Tp __result_type;530  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::acos(__x); }531};532 533template <class _Tp>534struct __asin_expr {535  typedef _Tp __result_type;536  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::asin(__x); }537};538 539template <class _Tp>540struct __atan_expr {541  typedef _Tp __result_type;542  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::atan(__x); }543};544 545template <class _Tp>546struct __atan2_expr {547  typedef _Tp __result_type;548  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::atan2(__x, __y); }549};550 551template <class _Tp>552struct __cos_expr {553  typedef _Tp __result_type;554  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cos(__x); }555};556 557template <class _Tp>558struct __cosh_expr {559  typedef _Tp __result_type;560  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cosh(__x); }561};562 563template <class _Tp>564struct __exp_expr {565  typedef _Tp __result_type;566  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::exp(__x); }567};568 569template <class _Tp>570struct __log_expr {571  typedef _Tp __result_type;572  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log(__x); }573};574 575template <class _Tp>576struct __log10_expr {577  typedef _Tp __result_type;578  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log10(__x); }579};580 581template <class _Tp>582struct __pow_expr {583  typedef _Tp __result_type;584  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::pow(__x, __y); }585};586 587template <class _Tp>588struct __sin_expr {589  typedef _Tp __result_type;590  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sin(__x); }591};592 593template <class _Tp>594struct __sinh_expr {595  typedef _Tp __result_type;596  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sinh(__x); }597};598 599template <class _Tp>600struct __sqrt_expr {601  typedef _Tp __result_type;602  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sqrt(__x); }603};604 605template <class _Tp>606struct __tan_expr {607  typedef _Tp __result_type;608  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tan(__x); }609};610 611template <class _Tp>612struct __tanh_expr {613  typedef _Tp __result_type;614  _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tanh(__x); }615};616 617template <class _ValExpr>618class __slice_expr {619  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;620 621public:622  typedef typename _RmExpr::value_type value_type;623  typedef value_type __result_type;624 625private:626  _ValExpr __expr_;627  size_t __start_;628  size_t __size_;629  size_t __stride_;630 631  _LIBCPP_HIDE_FROM_ABI __slice_expr(const slice& __sl, const _RmExpr& __e)632      : __expr_(__e), __start_(__sl.start()), __size_(__sl.size()), __stride_(__sl.stride()) {}633 634public:635  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__start_ + __i * __stride_]; }636 637  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }638 639  template <class>640  friend class __val_expr;641  template <class>642  friend class valarray;643};644 645template <class _ValExpr>646class __mask_expr;647 648template <class _ValExpr>649class __indirect_expr;650 651template <class _ValExpr>652class __shift_expr {653  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;654 655public:656  typedef typename _RmExpr::value_type value_type;657  typedef value_type __result_type;658 659private:660  _ValExpr __expr_;661  size_t __size_;662  ptrdiff_t __ul_;663  ptrdiff_t __sn_;664  ptrdiff_t __n_;665  static const ptrdiff_t _Np = static_cast<ptrdiff_t>(sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);666 667  _LIBCPP_HIDE_FROM_ABI __shift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()), __n_(__n) {668    ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);669    __sn_             = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);670    __ul_             = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);671  }672 673public:674  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __j) const {675    ptrdiff_t __i = static_cast<ptrdiff_t>(__j);676    ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;677    return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);678  }679 680  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }681 682  template <class>683  friend class __val_expr;684};685 686template <class _ValExpr>687class __cshift_expr {688  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;689 690public:691  typedef typename _RmExpr::value_type value_type;692  typedef value_type __result_type;693 694private:695  _ValExpr __expr_;696  size_t __size_;697  size_t __m_;698  size_t __o1_;699  size_t __o2_;700 701  _LIBCPP_HIDE_FROM_ABI __cshift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()) {702    __n %= static_cast<int>(__size_);703    if (__n >= 0) {704      __m_  = __size_ - __n;705      __o1_ = __n;706      __o2_ = __n - __size_;707    } else {708      __m_  = -__n;709      __o1_ = __n + __size_;710      __o2_ = __n;711    }712  }713 714public:715  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const {716    if (__i < __m_)717      return __expr_[__i + __o1_];718    return __expr_[__i + __o2_];719  }720 721  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }722 723  template <class>724  friend class __val_expr;725};726 727template <class _ValExpr>728class __val_expr;729 730template <class _ValExpr>731struct __is_val_expr : false_type {};732 733template <class _ValExpr>734struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};735 736template <class _Tp>737struct __is_val_expr<valarray<_Tp> > : true_type {};738 739template <class _Tp>740struct __is_val_expr<slice_array<_Tp> > : true_type {};741 742template <class _Tp>743struct __is_val_expr<gslice_array<_Tp> > : true_type {};744 745template <class _Tp>746struct __is_val_expr<mask_array<_Tp> > : true_type {};747 748template <class _Tp>749struct __is_val_expr<indirect_array<_Tp> > : true_type {};750 751// The functions using a __val_expr access the elements by their index.752// valarray and the libc++ lazy proxies have an operator[]. The753// Standard proxy array's don't have this operator, instead they have a754// implementation specific accessor755//   __get(size_t)756//757// The functions use the non-member function758//   __get(__val_expr, size_t)759//760// If the __val_expr is a specialization of __val_expr_use_member_functions it761// uses the __val_expr's member function762//   __get(size_t)763// else it uses the __val_expr's member function764//   operator[](size_t)765template <class _ValExpr>766struct __val_expr_use_member_functions;767 768template <class>769struct __val_expr_use_member_functions : false_type {};770 771template <class _Tp>772struct __val_expr_use_member_functions<slice_array<_Tp> > : true_type {};773 774template <class _Tp>775struct __val_expr_use_member_functions<gslice_array<_Tp> > : true_type {};776 777template <class _Tp>778struct __val_expr_use_member_functions<mask_array<_Tp> > : true_type {};779 780template <class _Tp>781struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {};782 783template <class _Tp>784class valarray {785public:786  typedef _Tp value_type;787  typedef _Tp __result_type;788 789private:790  value_type* __begin_;791  value_type* __end_;792 793public:794  // construct/destroy:795  _LIBCPP_HIDE_FROM_ABI valarray() : __begin_(nullptr), __end_(nullptr) {}796  inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit valarray(size_t __n);797  _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n);798  valarray(const value_type* __p, size_t __n);799  valarray(const valarray& __v);800#  ifndef _LIBCPP_CXX03_LANG801  _LIBCPP_HIDE_FROM_ABI valarray(valarray&& __v) _NOEXCEPT;802  valarray(initializer_list<value_type> __il);803#  endif // _LIBCPP_CXX03_LANG804  valarray(const slice_array<value_type>& __sa);805  valarray(const gslice_array<value_type>& __ga);806  valarray(const mask_array<value_type>& __ma);807  valarray(const indirect_array<value_type>& __ia);808  inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 ~valarray();809 810  // assignment:811  valarray& operator=(const valarray& __v);812#  ifndef _LIBCPP_CXX03_LANG813  _LIBCPP_HIDE_FROM_ABI valarray& operator=(valarray&& __v) _NOEXCEPT;814  _LIBCPP_HIDE_FROM_ABI valarray& operator=(initializer_list<value_type>);815#  endif // _LIBCPP_CXX03_LANG816  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x);817  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa);818  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga);819  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const mask_array<value_type>& __ma);820  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const indirect_array<value_type>& __ia);821  template <class _ValExpr>822  _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v);823 824  // element access:825  _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const {826    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds");827    return __begin_[__i];828  }829 830  _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) {831    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds");832    return __begin_[__i];833  }834 835  // subset operations:836  _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;837  _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s);838  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;839  _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs);840#  ifndef _LIBCPP_CXX03_LANG841  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;842  _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs);843#  endif // _LIBCPP_CXX03_LANG844  _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;845  _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb);846#  ifndef _LIBCPP_CXX03_LANG847  _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;848  _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb);849#  endif // _LIBCPP_CXX03_LANG850  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;851  _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs);852#  ifndef _LIBCPP_CXX03_LANG853  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;854  _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs);855#  endif // _LIBCPP_CXX03_LANG856 857  // unary operators:858  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;859  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const;860  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const;861  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const;862 863  // computed assignment:864  _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const value_type& __x);865  _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const value_type& __x);866  _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const value_type& __x);867  _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const value_type& __x);868  _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const value_type& __x);869  _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const value_type& __x);870  _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const value_type& __x);871  _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const value_type& __x);872  _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const value_type& __x);873  _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const value_type& __x);874 875  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>876  _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const _Expr& __v);877 878  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>879  _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const _Expr& __v);880 881  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>882  _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const _Expr& __v);883 884  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>885  _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const _Expr& __v);886 887  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>888  _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const _Expr& __v);889 890  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>891  _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const _Expr& __v);892 893  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>894  _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const _Expr& __v);895 896  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>897  _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const _Expr& __v);898 899  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>900  _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const _Expr& __v);901 902  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>903  _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const _Expr& __v);904 905  // member functions:906  _LIBCPP_HIDE_FROM_ABI void swap(valarray& __v) _NOEXCEPT;907 908  _LIBCPP_HIDE_FROM_ABI size_t size() const { return static_cast<size_t>(__end_ - __begin_); }909 910  _LIBCPP_HIDE_FROM_ABI value_type sum() const;911  _LIBCPP_HIDE_FROM_ABI value_type min() const;912  _LIBCPP_HIDE_FROM_ABI value_type max() const;913 914  valarray shift(int __i) const;915  valarray cshift(int __i) const;916  valarray apply(value_type __f(value_type)) const;917  valarray apply(value_type __f(const value_type&)) const;918  void resize(size_t __n, value_type __x = value_type());919 920private:921  template <class>922  friend class valarray;923  template <class>924  friend class slice_array;925  template <class>926  friend class gslice_array;927  template <class>928  friend class mask_array;929  template <class>930  friend class __mask_expr;931  template <class>932  friend class indirect_array;933  template <class>934  friend class __indirect_expr;935  template <class>936  friend class __val_expr;937 938  template <class _Up>939  friend _Up* begin(valarray<_Up>& __v);940 941  template <class _Up>942  friend const _Up* begin(const valarray<_Up>& __v);943 944  template <class _Up>945  friend _Up* end(valarray<_Up>& __v);946 947  template <class _Up>948  friend const _Up* end(const valarray<_Up>& __v);949 950  _LIBCPP_HIDE_FROM_ABI void __clear(size_t __capacity);951  valarray& __assign_range(const value_type* __f, const value_type* __l);952};953 954#  if _LIBCPP_STD_VER >= 17955template <class _Tp, size_t _Size>956valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>;957#  endif958 959template <class _Expr,960          __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0>961_LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {962  return __v.__get(__i);963}964 965template <class _Expr,966          __enable_if_t<__is_val_expr<_Expr>::value && !__val_expr_use_member_functions<_Expr>::value, int> = 0>967_LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {968  return __v[__i];969}970 971extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t);972 973template <class _Op, class _Tp>974struct _UnaryOp<_Op, valarray<_Tp> > {975  typedef typename _Op::__result_type __result_type;976  using value_type = __decay_t<__result_type>;977 978  _Op __op_;979  const valarray<_Tp>& __a0_;980 981  _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}982 983  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); }984 985  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }986};987 988template <class _Op, class _Tp, class _A1>989struct _BinaryOp<_Op, valarray<_Tp>, _A1> {990  typedef typename _Op::__result_type __result_type;991  using value_type = __decay_t<__result_type>;992 993  _Op __op_;994  const valarray<_Tp>& __a0_;995  _A1 __a1_;996 997  _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)998      : __op_(__op), __a0_(__a0), __a1_(__a1) {}999 1000  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }1001 1002  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }1003};1004 1005template <class _Op, class _A0, class _Tp>1006struct _BinaryOp<_Op, _A0, valarray<_Tp> > {1007  typedef typename _Op::__result_type __result_type;1008  using value_type = __decay_t<__result_type>;1009 1010  _Op __op_;1011  _A0 __a0_;1012  const valarray<_Tp>& __a1_;1013 1014  _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)1015      : __op_(__op), __a0_(__a0), __a1_(__a1) {}1016 1017  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }1018 1019  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }1020};1021 1022template <class _Op, class _Tp>1023struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > {1024  typedef typename _Op::__result_type __result_type;1025  using value_type = __decay_t<__result_type>;1026 1027  _Op __op_;1028  const valarray<_Tp>& __a0_;1029  const valarray<_Tp>& __a1_;1030 1031  _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)1032      : __op_(__op), __a0_(__a0), __a1_(__a1) {}1033 1034  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); }1035 1036  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); }1037};1038 1039// slice_array1040 1041template <class _Tp>1042class slice_array {1043public:1044  typedef _Tp value_type;1045 1046private:1047  value_type* __vp_;1048  size_t __size_;1049  size_t __stride_;1050 1051public:1052  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1053  void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;1054 1055  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1056  void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;1057 1058  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1059  void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;1060 1061  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1062  void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;1063 1064  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1065  void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;1066 1067  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1068  void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;1069 1070  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1071  void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;1072 1073  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1074  void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;1075 1076  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1077  void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;1078 1079  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1080  void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;1081 1082  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1083  void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;1084 1085  slice_array(slice_array const&) = default;1086 1087  _LIBCPP_HIDE_FROM_ABI const slice_array& operator=(const slice_array& __sa) const;1088 1089  _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;1090 1091  _LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const;1092 1093  // Behaves like __val_expr::operator[], which returns by value.1094  _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {1095    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "slice_array.__get() index out of bounds");1096    return __vp_[__i * __stride_];1097  }1098 1099private:1100  _LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v)1101      : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {}1102 1103  template <class>1104  friend class valarray;1105};1106 1107template <class _Tp>1108inline const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const {1109  value_type* __t       = __vp_;1110  const value_type* __s = __sa.__vp_;1111  for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)1112    *__t = *__s;1113  return *this;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>1125inline void slice_array<_Tp>::operator=(const valarray<value_type>& __va) const {1126  value_type* __t = __vp_;1127  for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)1128    *__t = __va[__i];1129}1130 1131template <class _Tp>1132template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1133inline void slice_array<_Tp>::operator*=(const _Expr& __v) const {1134  value_type* __t = __vp_;1135  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1136    *__t *= __v[__i];1137}1138 1139template <class _Tp>1140template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1141inline void slice_array<_Tp>::operator/=(const _Expr& __v) const {1142  value_type* __t = __vp_;1143  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1144    *__t /= __v[__i];1145}1146 1147template <class _Tp>1148template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1149inline void slice_array<_Tp>::operator%=(const _Expr& __v) const {1150  value_type* __t = __vp_;1151  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1152    *__t %= __v[__i];1153}1154 1155template <class _Tp>1156template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1157inline void slice_array<_Tp>::operator+=(const _Expr& __v) const {1158  value_type* __t = __vp_;1159  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1160    *__t += __v[__i];1161}1162 1163template <class _Tp>1164template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1165inline void slice_array<_Tp>::operator-=(const _Expr& __v) const {1166  value_type* __t = __vp_;1167  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1168    *__t -= __v[__i];1169}1170 1171template <class _Tp>1172template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1173inline void slice_array<_Tp>::operator^=(const _Expr& __v) const {1174  value_type* __t = __vp_;1175  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1176    *__t ^= __v[__i];1177}1178 1179template <class _Tp>1180template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1181inline void slice_array<_Tp>::operator&=(const _Expr& __v) const {1182  value_type* __t = __vp_;1183  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1184    *__t &= __v[__i];1185}1186 1187template <class _Tp>1188template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1189inline void slice_array<_Tp>::operator|=(const _Expr& __v) const {1190  value_type* __t = __vp_;1191  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1192    *__t |= __v[__i];1193}1194 1195template <class _Tp>1196template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1197inline void slice_array<_Tp>::operator<<=(const _Expr& __v) const {1198  value_type* __t = __vp_;1199  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1200    *__t <<= __v[__i];1201}1202 1203template <class _Tp>1204template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1205inline void slice_array<_Tp>::operator>>=(const _Expr& __v) const {1206  value_type* __t = __vp_;1207  for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)1208    *__t >>= __v[__i];1209}1210 1211template <class _Tp>1212inline void slice_array<_Tp>::operator=(const value_type& __x) const {1213  value_type* __t = __vp_;1214  for (size_t __n = __size_; __n; --__n, __t += __stride_)1215    *__t = __x;1216}1217 1218// gslice1219 1220class _LIBCPP_EXPORTED_FROM_ABI gslice {1221  valarray<size_t> __size_;1222  valarray<size_t> __stride_;1223  valarray<size_t> __1d_;1224 1225public:1226  _LIBCPP_HIDE_FROM_ABI gslice() {}1227 1228  _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, const valarray<size_t>& __stride)1229      : __size_(__size), __stride_(__stride) {1230    __init(__start);1231  }1232 1233#  ifndef _LIBCPP_CXX03_LANG1234 1235  _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, valarray<size_t>&& __stride)1236      : __size_(__size), __stride_(std::move(__stride)) {1237    __init(__start);1238  }1239 1240  _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, valarray<size_t>&& __size, const valarray<size_t>& __stride)1241      : __size_(std::move(__size)), __stride_(__stride) {1242    __init(__start);1243  }1244 1245  _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, valarray<size_t>&& __size, valarray<size_t>&& __stride)1246      : __size_(std::move(__size)), __stride_(std::move(__stride)) {1247    __init(__start);1248  }1249 1250#  endif // _LIBCPP_CXX03_LANG1251 1252  _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; }1253 1254  _LIBCPP_HIDE_FROM_ABI valarray<size_t> size() const { return __size_; }1255 1256  _LIBCPP_HIDE_FROM_ABI valarray<size_t> stride() const { return __stride_; }1257 1258private:1259  void __init(size_t __start);1260 1261  template <class>1262  friend class gslice_array;1263  template <class>1264  friend class valarray;1265  template <class>1266  friend class __val_expr;1267};1268 1269// gslice_array1270 1271template <class _Tp>1272class gslice_array {1273public:1274  typedef _Tp value_type;1275 1276private:1277  value_type* __vp_;1278  valarray<size_t> __1d_;1279 1280public:1281  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1282  void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;1283 1284  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1285  void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;1286 1287  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1288  void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;1289 1290  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1291  void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;1292 1293  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1294  void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;1295 1296  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1297  void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;1298 1299  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1300  void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;1301 1302  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1303  void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;1304 1305  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1306  void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;1307 1308  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1309  void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;1310 1311  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1312  void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;1313 1314  _LIBCPP_HIDE_FROM_ABI const gslice_array& operator=(const gslice_array& __ga) const;1315 1316  _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;1317 1318  gslice_array(const gslice_array&) = default;1319 1320  // Behaves like __val_expr::operator[], which returns by value.1321  _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {1322    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "gslice_array.__get() index out of bounds");1323    return __vp_[__1d_[__i]];1324  }1325 1326private:1327  gslice_array(const gslice& __gs, const valarray<value_type>& __v)1328      : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {}1329 1330#  ifndef _LIBCPP_CXX03_LANG1331  gslice_array(gslice&& __gs, const valarray<value_type>& __v)1332      : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__gs.__1d_)) {}1333#  endif // _LIBCPP_CXX03_LANG1334 1335  template <class>1336  friend class valarray;1337};1338 1339template <class _Tp>1340template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1341inline void gslice_array<_Tp>::operator=(const _Expr& __v) const {1342  typedef const size_t* _Ip;1343  size_t __j = 0;1344  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1345    __vp_[*__i] = __v[__j];1346}1347 1348template <class _Tp>1349template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1350inline void gslice_array<_Tp>::operator*=(const _Expr& __v) const {1351  typedef const size_t* _Ip;1352  size_t __j = 0;1353  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1354    __vp_[*__i] *= __v[__j];1355}1356 1357template <class _Tp>1358template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1359inline void gslice_array<_Tp>::operator/=(const _Expr& __v) const {1360  typedef const size_t* _Ip;1361  size_t __j = 0;1362  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1363    __vp_[*__i] /= __v[__j];1364}1365 1366template <class _Tp>1367template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1368inline void gslice_array<_Tp>::operator%=(const _Expr& __v) const {1369  typedef const size_t* _Ip;1370  size_t __j = 0;1371  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1372    __vp_[*__i] %= __v[__j];1373}1374 1375template <class _Tp>1376template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1377inline void gslice_array<_Tp>::operator+=(const _Expr& __v) const {1378  typedef const size_t* _Ip;1379  size_t __j = 0;1380  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1381    __vp_[*__i] += __v[__j];1382}1383 1384template <class _Tp>1385template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1386inline void gslice_array<_Tp>::operator-=(const _Expr& __v) const {1387  typedef const size_t* _Ip;1388  size_t __j = 0;1389  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1390    __vp_[*__i] -= __v[__j];1391}1392 1393template <class _Tp>1394template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1395inline void gslice_array<_Tp>::operator^=(const _Expr& __v) const {1396  typedef const size_t* _Ip;1397  size_t __j = 0;1398  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1399    __vp_[*__i] ^= __v[__j];1400}1401 1402template <class _Tp>1403template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1404inline void gslice_array<_Tp>::operator&=(const _Expr& __v) const {1405  typedef const size_t* _Ip;1406  size_t __j = 0;1407  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1408    __vp_[*__i] &= __v[__j];1409}1410 1411template <class _Tp>1412template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1413inline void gslice_array<_Tp>::operator|=(const _Expr& __v) const {1414  typedef const size_t* _Ip;1415  size_t __j = 0;1416  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1417    __vp_[*__i] |= __v[__j];1418}1419 1420template <class _Tp>1421template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1422inline void gslice_array<_Tp>::operator<<=(const _Expr& __v) const {1423  typedef const size_t* _Ip;1424  size_t __j = 0;1425  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1426    __vp_[*__i] <<= __v[__j];1427}1428 1429template <class _Tp>1430template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1431inline void gslice_array<_Tp>::operator>>=(const _Expr& __v) const {1432  typedef const size_t* _Ip;1433  size_t __j = 0;1434  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)1435    __vp_[*__i] >>= __v[__j];1436}1437 1438template <class _Tp>1439inline const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const {1440  typedef const size_t* _Ip;1441  const value_type* __s = __ga.__vp_;1442  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; __i != __e; ++__i, ++__j)1443    __vp_[*__i] = __s[*__j];1444  return *this;1445}1446 1447template <class _Tp>1448inline void gslice_array<_Tp>::operator=(const value_type& __x) const {1449  typedef const size_t* _Ip;1450  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)1451    __vp_[*__i] = __x;1452}1453 1454// mask_array1455 1456template <class _Tp>1457class mask_array {1458public:1459  typedef _Tp value_type;1460 1461private:1462  value_type* __vp_;1463  valarray<size_t> __1d_;1464 1465public:1466  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1467  void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;1468 1469  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1470  void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;1471 1472  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1473  void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;1474 1475  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1476  void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;1477 1478  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1479  void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;1480 1481  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1482  void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;1483 1484  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1485  void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;1486 1487  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1488  void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;1489 1490  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1491  void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;1492 1493  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1494  void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;1495 1496  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1497  void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;1498 1499  mask_array(const mask_array&) = default;1500 1501  _LIBCPP_HIDE_FROM_ABI const mask_array& operator=(const mask_array& __ma) const;1502 1503  _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;1504 1505  // Behaves like __val_expr::operator[], which returns by value.1506  _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {1507    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "mask_array.__get() index out of bounds");1508    return __vp_[__1d_[__i]];1509  }1510 1511private:1512  _LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)1513      : __vp_(const_cast<value_type*>(__v.__begin_)),1514        __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) {1515    size_t __j = 0;1516    for (size_t __i = 0; __i < __vb.size(); ++__i)1517      if (__vb[__i])1518        __1d_[__j++] = __i;1519  }1520 1521  template <class>1522  friend class valarray;1523};1524 1525template <class _Tp>1526template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1527inline void mask_array<_Tp>::operator=(const _Expr& __v) const {1528  size_t __n = __1d_.size();1529  for (size_t __i = 0; __i < __n; ++__i)1530    __vp_[__1d_[__i]] = __v[__i];1531}1532 1533template <class _Tp>1534template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1535inline void mask_array<_Tp>::operator*=(const _Expr& __v) const {1536  size_t __n = __1d_.size();1537  for (size_t __i = 0; __i < __n; ++__i)1538    __vp_[__1d_[__i]] *= __v[__i];1539}1540 1541template <class _Tp>1542template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1543inline void mask_array<_Tp>::operator/=(const _Expr& __v) const {1544  size_t __n = __1d_.size();1545  for (size_t __i = 0; __i < __n; ++__i)1546    __vp_[__1d_[__i]] /= __v[__i];1547}1548 1549template <class _Tp>1550template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1551inline void mask_array<_Tp>::operator%=(const _Expr& __v) const {1552  size_t __n = __1d_.size();1553  for (size_t __i = 0; __i < __n; ++__i)1554    __vp_[__1d_[__i]] %= __v[__i];1555}1556 1557template <class _Tp>1558template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1559inline void mask_array<_Tp>::operator+=(const _Expr& __v) const {1560  size_t __n = __1d_.size();1561  for (size_t __i = 0; __i < __n; ++__i)1562    __vp_[__1d_[__i]] += __v[__i];1563}1564 1565template <class _Tp>1566template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1567inline void mask_array<_Tp>::operator-=(const _Expr& __v) const {1568  size_t __n = __1d_.size();1569  for (size_t __i = 0; __i < __n; ++__i)1570    __vp_[__1d_[__i]] -= __v[__i];1571}1572 1573template <class _Tp>1574template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1575inline void mask_array<_Tp>::operator^=(const _Expr& __v) const {1576  size_t __n = __1d_.size();1577  for (size_t __i = 0; __i < __n; ++__i)1578    __vp_[__1d_[__i]] ^= __v[__i];1579}1580 1581template <class _Tp>1582template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1583inline void mask_array<_Tp>::operator&=(const _Expr& __v) const {1584  size_t __n = __1d_.size();1585  for (size_t __i = 0; __i < __n; ++__i)1586    __vp_[__1d_[__i]] &= __v[__i];1587}1588 1589template <class _Tp>1590template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1591inline void mask_array<_Tp>::operator|=(const _Expr& __v) const {1592  size_t __n = __1d_.size();1593  for (size_t __i = 0; __i < __n; ++__i)1594    __vp_[__1d_[__i]] |= __v[__i];1595}1596 1597template <class _Tp>1598template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1599inline void mask_array<_Tp>::operator<<=(const _Expr& __v) const {1600  size_t __n = __1d_.size();1601  for (size_t __i = 0; __i < __n; ++__i)1602    __vp_[__1d_[__i]] <<= __v[__i];1603}1604 1605template <class _Tp>1606template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1607inline void mask_array<_Tp>::operator>>=(const _Expr& __v) const {1608  size_t __n = __1d_.size();1609  for (size_t __i = 0; __i < __n; ++__i)1610    __vp_[__1d_[__i]] >>= __v[__i];1611}1612 1613template <class _Tp>1614inline const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const {1615  size_t __n = __1d_.size();1616  for (size_t __i = 0; __i < __n; ++__i)1617    __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];1618  return *this;1619}1620 1621template <class _Tp>1622inline void mask_array<_Tp>::operator=(const value_type& __x) const {1623  size_t __n = __1d_.size();1624  for (size_t __i = 0; __i < __n; ++__i)1625    __vp_[__1d_[__i]] = __x;1626}1627 1628template <class _ValExpr>1629class __mask_expr {1630  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;1631 1632public:1633  typedef typename _RmExpr::value_type value_type;1634  typedef value_type __result_type;1635 1636private:1637  _ValExpr __expr_;1638  valarray<size_t> __1d_;1639 1640  _LIBCPP_HIDE_FROM_ABI __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)1641      : __expr_(__e), __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) {1642    size_t __j = 0;1643    for (size_t __i = 0; __i < __vb.size(); ++__i)1644      if (__vb[__i])1645        __1d_[__j++] = __i;1646  }1647 1648public:1649  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }1650 1651  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); }1652 1653  template <class>1654  friend class __val_expr;1655  template <class>1656  friend class valarray;1657};1658 1659// indirect_array1660 1661template <class _Tp>1662class indirect_array {1663public:1664  typedef _Tp value_type;1665 1666private:1667  value_type* __vp_;1668  valarray<size_t> __1d_;1669 1670public:1671  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1672  void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const;1673 1674  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1675  void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const;1676 1677  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1678  void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const;1679 1680  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1681  void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const;1682 1683  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1684  void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const;1685 1686  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1687  void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const;1688 1689  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1690  void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const;1691 1692  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1693  void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const;1694 1695  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1696  void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const;1697 1698  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1699  void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const;1700 1701  template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>1702  void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const;1703 1704  indirect_array(const indirect_array&) = default;1705 1706  _LIBCPP_HIDE_FROM_ABI const indirect_array& operator=(const indirect_array& __ia) const;1707 1708  _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;1709 1710  // Behaves like __val_expr::operator[], which returns by value.1711  _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {1712    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "indirect_array.__get() index out of bounds");1713    return __vp_[__1d_[__i]];1714  }1715 1716private:1717  _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)1718      : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {}1719 1720#  ifndef _LIBCPP_CXX03_LANG1721 1722  _LIBCPP_HIDE_FROM_ABI indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)1723      : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__ia)) {}1724 1725#  endif // _LIBCPP_CXX03_LANG1726 1727  template <class>1728  friend class valarray;1729};1730 1731template <class _Tp>1732template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1733inline void indirect_array<_Tp>::operator=(const _Expr& __v) const {1734  size_t __n = __1d_.size();1735  for (size_t __i = 0; __i < __n; ++__i)1736    __vp_[__1d_[__i]] = __v[__i];1737}1738 1739template <class _Tp>1740template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1741inline void indirect_array<_Tp>::operator*=(const _Expr& __v) const {1742  size_t __n = __1d_.size();1743  for (size_t __i = 0; __i < __n; ++__i)1744    __vp_[__1d_[__i]] *= __v[__i];1745}1746 1747template <class _Tp>1748template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1749inline void indirect_array<_Tp>::operator/=(const _Expr& __v) const {1750  size_t __n = __1d_.size();1751  for (size_t __i = 0; __i < __n; ++__i)1752    __vp_[__1d_[__i]] /= __v[__i];1753}1754 1755template <class _Tp>1756template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1757inline void indirect_array<_Tp>::operator%=(const _Expr& __v) const {1758  size_t __n = __1d_.size();1759  for (size_t __i = 0; __i < __n; ++__i)1760    __vp_[__1d_[__i]] %= __v[__i];1761}1762 1763template <class _Tp>1764template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1765inline void indirect_array<_Tp>::operator+=(const _Expr& __v) const {1766  size_t __n = __1d_.size();1767  for (size_t __i = 0; __i < __n; ++__i)1768    __vp_[__1d_[__i]] += __v[__i];1769}1770 1771template <class _Tp>1772template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1773inline void indirect_array<_Tp>::operator-=(const _Expr& __v) const {1774  size_t __n = __1d_.size();1775  for (size_t __i = 0; __i < __n; ++__i)1776    __vp_[__1d_[__i]] -= __v[__i];1777}1778 1779template <class _Tp>1780template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1781inline void indirect_array<_Tp>::operator^=(const _Expr& __v) const {1782  size_t __n = __1d_.size();1783  for (size_t __i = 0; __i < __n; ++__i)1784    __vp_[__1d_[__i]] ^= __v[__i];1785}1786 1787template <class _Tp>1788template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1789inline void indirect_array<_Tp>::operator&=(const _Expr& __v) const {1790  size_t __n = __1d_.size();1791  for (size_t __i = 0; __i < __n; ++__i)1792    __vp_[__1d_[__i]] &= __v[__i];1793}1794 1795template <class _Tp>1796template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1797inline void indirect_array<_Tp>::operator|=(const _Expr& __v) const {1798  size_t __n = __1d_.size();1799  for (size_t __i = 0; __i < __n; ++__i)1800    __vp_[__1d_[__i]] |= __v[__i];1801}1802 1803template <class _Tp>1804template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1805inline void indirect_array<_Tp>::operator<<=(const _Expr& __v) const {1806  size_t __n = __1d_.size();1807  for (size_t __i = 0; __i < __n; ++__i)1808    __vp_[__1d_[__i]] <<= __v[__i];1809}1810 1811template <class _Tp>1812template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >1813inline void indirect_array<_Tp>::operator>>=(const _Expr& __v) const {1814  size_t __n = __1d_.size();1815  for (size_t __i = 0; __i < __n; ++__i)1816    __vp_[__1d_[__i]] >>= __v[__i];1817}1818 1819template <class _Tp>1820inline const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const {1821  typedef const size_t* _Ip;1822  const value_type* __s = __ia.__vp_;1823  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; __i != __e; ++__i, ++__j)1824    __vp_[*__i] = __s[*__j];1825  return *this;1826}1827 1828template <class _Tp>1829inline void indirect_array<_Tp>::operator=(const value_type& __x) const {1830  typedef const size_t* _Ip;1831  for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)1832    __vp_[*__i] = __x;1833}1834 1835template <class _ValExpr>1836class __indirect_expr {1837  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;1838 1839public:1840  typedef typename _RmExpr::value_type value_type;1841  typedef value_type __result_type;1842 1843private:1844  _ValExpr __expr_;1845  valarray<size_t> __1d_;1846 1847  _LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {}1848 1849#  ifndef _LIBCPP_CXX03_LANG1850 1851  _LIBCPP_HIDE_FROM_ABI __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)1852      : __expr_(__e), __1d_(std::move(__ia)) {}1853 1854#  endif // _LIBCPP_CXX03_LANG1855 1856public:1857  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }1858 1859  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); }1860 1861  template <class>1862  friend class __val_expr;1863  template <class>1864  friend class valarray;1865};1866 1867template <class _ValExpr>1868class __val_expr {1869  typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;1870 1871  _ValExpr __expr_;1872 1873public:1874  typedef typename _RmExpr::value_type value_type;1875  typedef typename _RmExpr::__result_type __result_type;1876 1877  _LIBCPP_HIDE_FROM_ABI explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}1878 1879  _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__i]; }1880 1881  _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const {1882    typedef __slice_expr<_ValExpr> _NewExpr;1883    return __val_expr< _NewExpr >(_NewExpr(__s, __expr_));1884  }1885 1886  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const {1887    typedef __indirect_expr<_ValExpr> _NewExpr;1888    return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_));1889  }1890 1891  _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const {1892    typedef __mask_expr<_ValExpr> _NewExpr;1893    return __val_expr< _NewExpr >(_NewExpr(__vb, __expr_));1894  }1895 1896  _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const {1897    typedef __indirect_expr<_ValExpr> _NewExpr;1898    return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_));1899  }1900 1901  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > operator+() const {1902    typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;1903    return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));1904  }1905 1906  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > operator-() const {1907    typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;1908    return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));1909  }1910 1911  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > operator~() const {1912    typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;1913    return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));1914  }1915 1916  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > operator!() const {1917    typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;1918    return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));1919  }1920 1921  operator valarray<__result_type>() const;1922 1923  _LIBCPP_HIDE_FROM_ABI size_t size() const { return __expr_.size(); }1924 1925  _LIBCPP_HIDE_FROM_ABI __result_type sum() const {1926    size_t __n        = __expr_.size();1927    __result_type __r = __n ? __expr_[0] : __result_type();1928    for (size_t __i = 1; __i < __n; ++__i)1929      __r += __expr_[__i];1930    return __r;1931  }1932 1933  _LIBCPP_HIDE_FROM_ABI __result_type min() const {1934    size_t __n        = size();1935    __result_type __r = __n ? (*this)[0] : __result_type();1936    for (size_t __i = 1; __i < __n; ++__i) {1937      __result_type __x = __expr_[__i];1938      if (__x < __r)1939        __r = __x;1940    }1941    return __r;1942  }1943 1944  _LIBCPP_HIDE_FROM_ABI __result_type max() const {1945    size_t __n        = size();1946    __result_type __r = __n ? (*this)[0] : __result_type();1947    for (size_t __i = 1; __i < __n; ++__i) {1948      __result_type __x = __expr_[__i];1949      if (__r < __x)1950        __r = __x;1951    }1952    return __r;1953  }1954 1955  _LIBCPP_HIDE_FROM_ABI __val_expr<__shift_expr<_ValExpr> > shift(int __i) const {1956    return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));1957  }1958 1959  _LIBCPP_HIDE_FROM_ABI __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const {1960    return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));1961  }1962 1963  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(value_type)>, _ValExpr> >1964  apply(value_type __f(value_type)) const {1965    typedef __apply_expr<value_type, value_type (*)(value_type)> _Op;1966    typedef _UnaryOp<_Op, _ValExpr> _NewExpr;1967    return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));1968  }1969 1970  _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(const value_type&)>, _ValExpr> >1971  apply(value_type __f(const value_type&)) const {1972    typedef __apply_expr<value_type, value_type (*)(const value_type&)> _Op;1973    typedef _UnaryOp<_Op, _ValExpr> _NewExpr;1974    return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));1975  }1976};1977 1978template <class _ValExpr>1979__val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const {1980  valarray<__result_type> __r;1981  size_t __n = __expr_.size();1982  if (__n) {1983    __r.__begin_ = __r.__end_ = allocator<__result_type>().allocate(__n);1984    for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)1985      ::new ((void*)__r.__end_) __result_type(__expr_[__i]);1986  }1987  return __r;1988}1989 1990// valarray1991 1992template <class _Tp>1993inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) {1994  if (__n) {1995    __begin_ = __end_ = allocator<value_type>().allocate(__n);1996    auto __guard      = std::__make_exception_guard([&] { __clear(__n); });1997    for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)1998      ::new ((void*)__end_) value_type();1999    __guard.__complete();2000  }2001}2002 2003template <class _Tp>2004inline valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(nullptr), __end_(nullptr) {2005  resize(__n, __x);2006}2007 2008template <class _Tp>2009valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) {2010  if (__n) {2011    __begin_ = __end_ = allocator<value_type>().allocate(__n);2012    auto __guard      = std::__make_exception_guard([&] { __clear(__n); });2013    for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)2014      ::new ((void*)__end_) value_type(*__p);2015    __guard.__complete();2016  }2017}2018 2019template <class _Tp>2020valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) {2021  if (__v.size()) {2022    __begin_ = __end_ = allocator<value_type>().allocate(__v.size());2023    auto __guard      = std::__make_exception_guard([&] { __clear(__v.size()); });2024    for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)2025      ::new ((void*)__end_) value_type(*__p);2026    __guard.__complete();2027  }2028}2029 2030#  ifndef _LIBCPP_CXX03_LANG2031 2032template <class _Tp>2033inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) {2034  __v.__begin_ = __v.__end_ = nullptr;2035}2036 2037template <class _Tp>2038valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr), __end_(nullptr) {2039  const size_t __n = __il.size();2040  if (__n) {2041    __begin_ = __end_ = allocator<value_type>().allocate(__n);2042    auto __guard      = std::__make_exception_guard([&] { __clear(__n); });2043    size_t __n_left   = __n;2044    for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)2045      ::new ((void*)__end_) value_type(*__p);2046    __guard.__complete();2047  }2048}2049 2050#  endif // _LIBCPP_CXX03_LANG2051 2052template <class _Tp>2053valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) {2054  const size_t __n = __sa.__size_;2055  if (__n) {2056    __begin_ = __end_ = allocator<value_type>().allocate(__n);2057    auto __guard      = std::__make_exception_guard([&] { __clear(__n); });2058    size_t __n_left   = __n;2059    for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)2060      ::new ((void*)__end_) value_type(*__p);2061    __guard.__complete();2062  }2063}2064 2065template <class _Tp>2066valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr), __end_(nullptr) {2067  const size_t __n = __ga.__1d_.size();2068  if (__n) {2069    __begin_ = __end_ = allocator<value_type>().allocate(__n);2070    auto __guard      = std::__make_exception_guard([&] { __clear(__n); });2071    typedef const size_t* _Ip;2072    const value_type* __s = __ga.__vp_;2073    for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_)2074      ::new ((void*)__end_) value_type(__s[*__i]);2075    __guard.__complete();2076  }2077}2078 2079template <class _Tp>2080valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), __end_(nullptr) {2081  const size_t __n = __ma.__1d_.size();2082  if (__n) {2083    __begin_ = __end_ = allocator<value_type>().allocate(__n);2084    auto __guard      = std::__make_exception_guard([&] { __clear(__n); });2085    typedef const size_t* _Ip;2086    const value_type* __s = __ma.__vp_;2087    for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_)2088      ::new ((void*)__end_) value_type(__s[*__i]);2089    __guard.__complete();2090  }2091}2092 2093template <class _Tp>2094valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullptr), __end_(nullptr) {2095  const size_t __n = __ia.__1d_.size();2096  if (__n) {2097    __begin_ = __end_ = allocator<value_type>().allocate(__n);2098    auto __guard      = std::__make_exception_guard([&] { __clear(__n); });2099    typedef const size_t* _Ip;2100    const value_type* __s = __ia.__vp_;2101    for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_)2102      ::new ((void*)__end_) value_type(__s[*__i]);2103    __guard.__complete();2104  }2105}2106 2107template <class _Tp>2108inline valarray<_Tp>::~valarray() {2109  __clear(size());2110}2111 2112template <class _Tp>2113valarray<_Tp>& valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) {2114  size_t __n = __l - __f;2115  if (size() != __n) {2116    __clear(size());2117    __begin_ = allocator<value_type>().allocate(__n);2118    __end_   = __begin_ + __n;2119    std::uninitialized_copy(__f, __l, __begin_);2120  } else {2121    std::copy(__f, __l, __begin_);2122  }2123  return *this;2124}2125 2126template <class _Tp>2127valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) {2128  if (this != std::addressof(__v))2129    return __assign_range(__v.__begin_, __v.__end_);2130  return *this;2131}2132 2133#  ifndef _LIBCPP_CXX03_LANG2134 2135template <class _Tp>2136inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT {2137  __clear(size());2138  __begin_     = __v.__begin_;2139  __end_       = __v.__end_;2140  __v.__begin_ = nullptr;2141  __v.__end_   = nullptr;2142  return *this;2143}2144 2145template <class _Tp>2146inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list<value_type> __il) {2147  return __assign_range(__il.begin(), __il.end());2148}2149 2150#  endif // _LIBCPP_CXX03_LANG2151 2152template <class _Tp>2153inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) {2154  std::fill(__begin_, __end_, __x);2155  return *this;2156}2157 2158template <class _Tp>2159inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<value_type>& __sa) {2160  value_type* __t       = __begin_;2161  const value_type* __s = __sa.__vp_;2162  for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)2163    *__t = *__s;2164  return *this;2165}2166 2167template <class _Tp>2168inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) {2169  typedef const size_t* _Ip;2170  value_type* __t       = __begin_;2171  const value_type* __s = __ga.__vp_;2172  for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__t)2173    *__t = __s[*__i];2174  return *this;2175}2176 2177template <class _Tp>2178inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<value_type>& __ma) {2179  typedef const size_t* _Ip;2180  value_type* __t       = __begin_;2181  const value_type* __s = __ma.__vp_;2182  for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__t)2183    *__t = __s[*__i];2184  return *this;2185}2186 2187template <class _Tp>2188inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) {2189  typedef const size_t* _Ip;2190  value_type* __t       = __begin_;2191  const value_type* __s = __ia.__vp_;2192  for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__t)2193    *__t = __s[*__i];2194  return *this;2195}2196 2197template <class _Tp>2198template <class _ValExpr>2199inline valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) {2200  size_t __n = __v.size();2201  if (size() != __n)2202    resize(__n);2203  value_type* __t = __begin_;2204  for (size_t __i = 0; __i != __n; ++__t, ++__i)2205    *__t = __result_type(__v[__i]);2206  return *this;2207}2208 2209template <class _Tp>2210inline __val_expr<__slice_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](slice __s) const {2211  return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));2212}2213 2214template <class _Tp>2215inline slice_array<_Tp> valarray<_Tp>::operator[](slice __s) {2216  return slice_array<value_type>(__s, *this);2217}2218 2219template <class _Tp>2220inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const gslice& __gs) const {2221  return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));2222}2223 2224template <class _Tp>2225inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) {2226  return gslice_array<value_type>(__gs, *this);2227}2228 2229#  ifndef _LIBCPP_CXX03_LANG2230 2231template <class _Tp>2232inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](gslice&& __gs) const {2233  return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this));2234}2235 2236template <class _Tp>2237inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) {2238  return gslice_array<value_type>(std::move(__gs), *this);2239}2240 2241#  endif // _LIBCPP_CXX03_LANG2242 2243template <class _Tp>2244inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const {2245  return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));2246}2247 2248template <class _Tp>2249inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) {2250  return mask_array<value_type>(__vb, *this);2251}2252 2253#  ifndef _LIBCPP_CXX03_LANG2254 2255template <class _Tp>2256inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<bool>&& __vb) const {2257  return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this));2258}2259 2260template <class _Tp>2261inline mask_array<_Tp> valarray<_Tp>::operator[](valarray<bool>&& __vb) {2262  return mask_array<value_type>(std::move(__vb), *this);2263}2264 2265#  endif // _LIBCPP_CXX03_LANG2266 2267template <class _Tp>2268inline __val_expr<__indirect_expr<const valarray<_Tp>&> >2269valarray<_Tp>::operator[](const valarray<size_t>& __vs) const {2270  return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));2271}2272 2273template <class _Tp>2274inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __vs) {2275  return indirect_array<value_type>(__vs, *this);2276}2277 2278#  ifndef _LIBCPP_CXX03_LANG2279 2280template <class _Tp>2281inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<size_t>&& __vs) const {2282  return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this));2283}2284 2285template <class _Tp>2286inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray<size_t>&& __vs) {2287  return indirect_array<value_type>(std::move(__vs), *this);2288}2289 2290#  endif // _LIBCPP_CXX03_LANG2291 2292template <class _Tp>2293inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const {2294  using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>;2295  return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this));2296}2297 2298template <class _Tp>2299inline __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator-() const {2300  using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>;2301  return __val_expr<_Op>(_Op(negate<_Tp>(), *this));2302}2303 2304template <class _Tp>2305inline __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator~() const {2306  using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>;2307  return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this));2308}2309 2310template <class _Tp>2311inline __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator!() const {2312  using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>;2313  return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this));2314}2315 2316template <class _Tp>2317inline valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) {2318  for (value_type* __p = __begin_; __p != __end_; ++__p)2319    *__p *= __x;2320  return *this;2321}2322 2323template <class _Tp>2324inline valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) {2325  for (value_type* __p = __begin_; __p != __end_; ++__p)2326    *__p /= __x;2327  return *this;2328}2329 2330template <class _Tp>2331inline valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) {2332  for (value_type* __p = __begin_; __p != __end_; ++__p)2333    *__p %= __x;2334  return *this;2335}2336 2337template <class _Tp>2338inline valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) {2339  for (value_type* __p = __begin_; __p != __end_; ++__p)2340    *__p += __x;2341  return *this;2342}2343 2344template <class _Tp>2345inline valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) {2346  for (value_type* __p = __begin_; __p != __end_; ++__p)2347    *__p -= __x;2348  return *this;2349}2350 2351template <class _Tp>2352inline valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) {2353  for (value_type* __p = __begin_; __p != __end_; ++__p)2354    *__p ^= __x;2355  return *this;2356}2357 2358template <class _Tp>2359inline valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) {2360  for (value_type* __p = __begin_; __p != __end_; ++__p)2361    *__p &= __x;2362  return *this;2363}2364 2365template <class _Tp>2366inline valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) {2367  for (value_type* __p = __begin_; __p != __end_; ++__p)2368    *__p |= __x;2369  return *this;2370}2371 2372template <class _Tp>2373inline valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) {2374  for (value_type* __p = __begin_; __p != __end_; ++__p)2375    *__p <<= __x;2376  return *this;2377}2378 2379template <class _Tp>2380inline valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) {2381  for (value_type* __p = __begin_; __p != __end_; ++__p)2382    *__p >>= __x;2383  return *this;2384}2385 2386template <class _Tp>2387template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2388inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) {2389  size_t __i = 0;2390  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2391    *__t *= std::__get(__v, __i);2392  return *this;2393}2394 2395template <class _Tp>2396template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2397inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) {2398  size_t __i = 0;2399  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2400    *__t /= std::__get(__v, __i);2401  return *this;2402}2403 2404template <class _Tp>2405template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2406inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) {2407  size_t __i = 0;2408  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2409    *__t %= std::__get(__v, __i);2410  return *this;2411}2412 2413template <class _Tp>2414template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2415inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) {2416  size_t __i = 0;2417  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2418    *__t += std::__get(__v, __i);2419  return *this;2420}2421 2422template <class _Tp>2423template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2424inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) {2425  size_t __i = 0;2426  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2427    *__t -= std::__get(__v, __i);2428  return *this;2429}2430 2431template <class _Tp>2432template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2433inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) {2434  size_t __i = 0;2435  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2436    *__t ^= std::__get(__v, __i);2437  return *this;2438}2439 2440template <class _Tp>2441template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2442inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) {2443  size_t __i = 0;2444  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2445    *__t |= std::__get(__v, __i);2446  return *this;2447}2448 2449template <class _Tp>2450template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2451inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) {2452  size_t __i = 0;2453  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2454    *__t &= std::__get(__v, __i);2455  return *this;2456}2457 2458template <class _Tp>2459template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2460inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) {2461  size_t __i = 0;2462  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2463    *__t <<= std::__get(__v, __i);2464  return *this;2465}2466 2467template <class _Tp>2468template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >2469inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) {2470  size_t __i = 0;2471  for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)2472    *__t >>= std::__get(__v, __i);2473  return *this;2474}2475 2476template <class _Tp>2477inline void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT {2478  std::swap(__begin_, __v.__begin_);2479  std::swap(__end_, __v.__end_);2480}2481 2482template <class _Tp>2483inline _Tp valarray<_Tp>::sum() const {2484  if (__begin_ == __end_)2485    return value_type();2486  const value_type* __p = __begin_;2487  _Tp __r               = *__p;2488  for (++__p; __p != __end_; ++__p)2489    __r += *__p;2490  return __r;2491}2492 2493template <class _Tp>2494inline _Tp valarray<_Tp>::min() const {2495  if (__begin_ == __end_)2496    return value_type();2497  return *std::min_element(__begin_, __end_);2498}2499 2500template <class _Tp>2501inline _Tp valarray<_Tp>::max() const {2502  if (__begin_ == __end_)2503    return value_type();2504  return *std::max_element(__begin_, __end_);2505}2506 2507template <class _Tp>2508valarray<_Tp> valarray<_Tp>::shift(int __i) const {2509  valarray<value_type> __r;2510  size_t __n = size();2511  if (__n) {2512    __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);2513    const value_type* __sb;2514    value_type* __tb;2515    value_type* __te;2516    if (__i >= 0) {2517      __i  = std::min(__i, static_cast<int>(__n));2518      __sb = __begin_ + __i;2519      __tb = __r.__begin_;2520      __te = __r.__begin_ + (__n - __i);2521    } else {2522      __i  = std::min(-__i, static_cast<int>(__n));2523      __sb = __begin_;2524      __tb = __r.__begin_ + __i;2525      __te = __r.__begin_ + __n;2526    }2527    for (; __r.__end_ != __tb; ++__r.__end_)2528      ::new ((void*)__r.__end_) value_type();2529    for (; __r.__end_ != __te; ++__r.__end_, ++__sb)2530      ::new ((void*)__r.__end_) value_type(*__sb);2531    for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)2532      ::new ((void*)__r.__end_) value_type();2533  }2534  return __r;2535}2536 2537template <class _Tp>2538valarray<_Tp> valarray<_Tp>::cshift(int __i) const {2539  valarray<value_type> __r;2540  size_t __n = size();2541  if (__n) {2542    __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);2543    __i %= static_cast<int>(__n);2544    const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;2545    for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)2546      ::new ((void*)__r.__end_) value_type(*__s);2547    for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)2548      ::new ((void*)__r.__end_) value_type(*__s);2549  }2550  return __r;2551}2552 2553template <class _Tp>2554valarray<_Tp> valarray<_Tp>::apply(value_type __f(value_type)) const {2555  valarray<value_type> __r;2556  size_t __n = size();2557  if (__n) {2558    __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);2559    for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)2560      ::new ((void*)__r.__end_) value_type(__f(*__p));2561  }2562  return __r;2563}2564 2565template <class _Tp>2566valarray<_Tp> valarray<_Tp>::apply(value_type __f(const value_type&)) const {2567  valarray<value_type> __r;2568  size_t __n = size();2569  if (__n) {2570    __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);2571    for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)2572      ::new ((void*)__r.__end_) value_type(__f(*__p));2573  }2574  return __r;2575}2576 2577template <class _Tp>2578inline void valarray<_Tp>::__clear(size_t __capacity) {2579  if (__begin_ != nullptr) {2580    while (__end_ != __begin_)2581      (--__end_)->~value_type();2582    allocator<value_type>().deallocate(__begin_, __capacity);2583    __begin_ = __end_ = nullptr;2584  }2585}2586 2587template <class _Tp>2588void valarray<_Tp>::resize(size_t __n, value_type __x) {2589  __clear(size());2590  if (__n) {2591    __begin_ = __end_ = allocator<value_type>().allocate(__n);2592    auto __guard      = std::__make_exception_guard([&] { __clear(__n); });2593    for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)2594      ::new ((void*)__end_) value_type(__x);2595    __guard.__complete();2596  }2597}2598 2599template <class _Tp>2600inline _LIBCPP_HIDE_FROM_ABI void swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT {2601  __x.swap(__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<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >2608operator*(const _Expr1& __x, const _Expr2& __y) {2609  typedef typename _Expr1::value_type value_type;2610  typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;2611  return __val_expr<_Op>(_Op(multiplies<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<multiplies<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<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;2620  return __val_expr<_Op>(_Op(multiplies<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<multiplies<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<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;2629  return __val_expr<_Op>(_Op(multiplies<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<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >2636operator/(const _Expr1& __x, const _Expr2& __y) {2637  typedef typename _Expr1::value_type value_type;2638  typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;2639  return __val_expr<_Op>(_Op(divides<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<divides<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<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;2648  return __val_expr<_Op>(_Op(divides<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<divides<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<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;2657  return __val_expr<_Op>(_Op(divides<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<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >2664operator%(const _Expr1& __x, const _Expr2& __y) {2665  typedef typename _Expr1::value_type value_type;2666  typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;2667  return __val_expr<_Op>(_Op(modulus<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<modulus<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<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;2676  return __val_expr<_Op>(_Op(modulus<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<modulus<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<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;2685  return __val_expr<_Op>(_Op(modulus<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<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >2692operator+(const _Expr1& __x, const _Expr2& __y) {2693  typedef typename _Expr1::value_type value_type;2694  typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;2695  return __val_expr<_Op>(_Op(plus<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<plus<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<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;2704  return __val_expr<_Op>(_Op(plus<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<plus<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<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;2713  return __val_expr<_Op>(_Op(plus<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<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >2720operator-(const _Expr1& __x, const _Expr2& __y) {2721  typedef typename _Expr1::value_type value_type;2722  typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;2723  return __val_expr<_Op>(_Op(minus<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<minus<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<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;2732  return __val_expr<_Op>(_Op(minus<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<minus<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<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;2741  return __val_expr<_Op>(_Op(minus<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_xor<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_xor<value_type>, _Expr1, _Expr2> _Op;2751  return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));2752}2753 2754template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2755inline _LIBCPP_HIDE_FROM_ABI2756__val_expr<_BinaryOp<bit_xor<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_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;2760  return __val_expr<_Op>(_Op(bit_xor<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_xor<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_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;2769  return __val_expr<_Op>(_Op(bit_xor<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<bit_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<bit_and<value_type>, _Expr1, _Expr2> _Op;2779  return __val_expr<_Op>(_Op(bit_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<bit_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<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;2788  return __val_expr<_Op>(_Op(bit_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<bit_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<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;2797  return __val_expr<_Op>(_Op(bit_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<bit_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<bit_or<value_type>, _Expr1, _Expr2> _Op;2807  return __val_expr<_Op>(_Op(bit_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<bit_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<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;2816  return __val_expr<_Op>(_Op(bit_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<bit_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<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;2825  return __val_expr<_Op>(_Op(bit_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<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >2832operator<<(const _Expr1& __x, const _Expr2& __y) {2833  typedef typename _Expr1::value_type value_type;2834  typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;2835  return __val_expr<_Op>(_Op(__bit_shift_left<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<__bit_shift_left<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<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;2844  return __val_expr<_Op>(_Op(__bit_shift_left<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<__bit_shift_left<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<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;2853  return __val_expr<_Op>(_Op(__bit_shift_left<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<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >2860operator>>(const _Expr1& __x, const _Expr2& __y) {2861  typedef typename _Expr1::value_type value_type;2862  typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;2863  return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));2864}2865 2866template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>2867inline _LIBCPP_HIDE_FROM_ABI __val_expr<2868    _BinaryOp<__bit_shift_right<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<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;2872  return __val_expr<_Op>(_Op(__bit_shift_right<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<__bit_shift_right<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<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;2881  return __val_expr<_Op>(_Op(__bit_shift_right<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<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >2888operator&&(const _Expr1& __x, const _Expr2& __y) {2889  typedef typename _Expr1::value_type value_type;2890  typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;2891  return __val_expr<_Op>(_Op(logical_and<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<logical_and<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<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;2900  return __val_expr<_Op>(_Op(logical_and<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<logical_and<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<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;2909  return __val_expr<_Op>(_Op(logical_and<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<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >2916operator||(const _Expr1& __x, const _Expr2& __y) {2917  typedef typename _Expr1::value_type value_type;2918  typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;2919  return __val_expr<_Op>(_Op(logical_or<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<logical_or<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<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;2928  return __val_expr<_Op>(_Op(logical_or<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<logical_or<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<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;2937  return __val_expr<_Op>(_Op(logical_or<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<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >2944operator==(const _Expr1& __x, const _Expr2& __y) {2945  typedef typename _Expr1::value_type value_type;2946  typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;2947  return __val_expr<_Op>(_Op(equal_to<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<equal_to<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<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;2956  return __val_expr<_Op>(_Op(equal_to<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<equal_to<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<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;2965  return __val_expr<_Op>(_Op(equal_to<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<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >2972operator!=(const _Expr1& __x, const _Expr2& __y) {2973  typedef typename _Expr1::value_type value_type;2974  typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;2975  return __val_expr<_Op>(_Op(not_equal_to<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<not_equal_to<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<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;2984  return __val_expr<_Op>(_Op(not_equal_to<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<not_equal_to<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<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;2993  return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));2994}2995 2996template <class _Expr1,2997          class _Expr2,2998          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>2999inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >3000operator<(const _Expr1& __x, const _Expr2& __y) {3001  typedef typename _Expr1::value_type value_type;3002  typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;3003  return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));3004}3005 3006template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3007inline _LIBCPP_HIDE_FROM_ABI3008__val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >3009operator<(const _Expr& __x, const typename _Expr::value_type& __y) {3010  typedef typename _Expr::value_type value_type;3011  typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;3012  return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));3013}3014 3015template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3016inline _LIBCPP_HIDE_FROM_ABI3017__val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >3018operator<(const typename _Expr::value_type& __x, const _Expr& __y) {3019  typedef typename _Expr::value_type value_type;3020  typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;3021  return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));3022}3023 3024template <class _Expr1,3025          class _Expr2,3026          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>3027inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >3028operator>(const _Expr1& __x, const _Expr2& __y) {3029  typedef typename _Expr1::value_type value_type;3030  typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;3031  return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));3032}3033 3034template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3035inline _LIBCPP_HIDE_FROM_ABI3036__val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >3037operator>(const _Expr& __x, const typename _Expr::value_type& __y) {3038  typedef typename _Expr::value_type value_type;3039  typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;3040  return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));3041}3042 3043template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3044inline _LIBCPP_HIDE_FROM_ABI3045__val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >3046operator>(const typename _Expr::value_type& __x, const _Expr& __y) {3047  typedef typename _Expr::value_type value_type;3048  typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;3049  return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));3050}3051 3052template <class _Expr1,3053          class _Expr2,3054          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>3055inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >3056operator<=(const _Expr1& __x, const _Expr2& __y) {3057  typedef typename _Expr1::value_type value_type;3058  typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;3059  return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));3060}3061 3062template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3063inline _LIBCPP_HIDE_FROM_ABI3064__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >3065operator<=(const _Expr& __x, const typename _Expr::value_type& __y) {3066  typedef typename _Expr::value_type value_type;3067  typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;3068  return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));3069}3070 3071template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3072inline _LIBCPP_HIDE_FROM_ABI3073__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >3074operator<=(const typename _Expr::value_type& __x, const _Expr& __y) {3075  typedef typename _Expr::value_type value_type;3076  typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;3077  return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));3078}3079 3080template <class _Expr1,3081          class _Expr2,3082          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>3083inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >3084operator>=(const _Expr1& __x, const _Expr2& __y) {3085  typedef typename _Expr1::value_type value_type;3086  typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;3087  return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));3088}3089 3090template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3091inline _LIBCPP_HIDE_FROM_ABI3092__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >3093operator>=(const _Expr& __x, const typename _Expr::value_type& __y) {3094  typedef typename _Expr::value_type value_type;3095  typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;3096  return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));3097}3098 3099template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3100inline _LIBCPP_HIDE_FROM_ABI3101__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >3102operator>=(const typename _Expr::value_type& __x, const _Expr& __y) {3103  typedef typename _Expr::value_type value_type;3104  typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;3105  return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));3106}3107 3108template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3109inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >3110abs(const _Expr& __x) {3111  typedef typename _Expr::value_type value_type;3112  typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;3113  return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));3114}3115 3116template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3117inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >3118acos(const _Expr& __x) {3119  typedef typename _Expr::value_type value_type;3120  typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;3121  return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));3122}3123 3124template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3125inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >3126asin(const _Expr& __x) {3127  typedef typename _Expr::value_type value_type;3128  typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;3129  return __val_expr<_Op>(_Op(__asin_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<__atan_expr<typename _Expr::value_type>, _Expr> >3134atan(const _Expr& __x) {3135  typedef typename _Expr::value_type value_type;3136  typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;3137  return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));3138}3139 3140template <class _Expr1,3141          class _Expr2,3142          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>3143inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >3144atan2(const _Expr1& __x, const _Expr2& __y) {3145  typedef typename _Expr1::value_type value_type;3146  typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;3147  return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));3148}3149 3150template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3151inline _LIBCPP_HIDE_FROM_ABI3152__val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >3153atan2(const _Expr& __x, const typename _Expr::value_type& __y) {3154  typedef typename _Expr::value_type value_type;3155  typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;3156  return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));3157}3158 3159template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3160inline _LIBCPP_HIDE_FROM_ABI3161__val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >3162atan2(const typename _Expr::value_type& __x, const _Expr& __y) {3163  typedef typename _Expr::value_type value_type;3164  typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;3165  return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));3166}3167 3168template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3169inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >3170cos(const _Expr& __x) {3171  typedef typename _Expr::value_type value_type;3172  typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;3173  return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));3174}3175 3176template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3177inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >3178cosh(const _Expr& __x) {3179  typedef typename _Expr::value_type value_type;3180  typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;3181  return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));3182}3183 3184template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3185inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >3186exp(const _Expr& __x) {3187  typedef typename _Expr::value_type value_type;3188  typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;3189  return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));3190}3191 3192template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3193inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >3194log(const _Expr& __x) {3195  typedef typename _Expr::value_type value_type;3196  typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;3197  return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));3198}3199 3200template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3201inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >3202log10(const _Expr& __x) {3203  typedef typename _Expr::value_type value_type;3204  typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;3205  return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));3206}3207 3208template <class _Expr1,3209          class _Expr2,3210          __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0>3211inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >3212pow(const _Expr1& __x, const _Expr2& __y) {3213  typedef typename _Expr1::value_type value_type;3214  typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;3215  return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));3216}3217 3218template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3219inline _LIBCPP_HIDE_FROM_ABI3220__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >3221pow(const _Expr& __x, const typename _Expr::value_type& __y) {3222  typedef typename _Expr::value_type value_type;3223  typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;3224  return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));3225}3226 3227template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3228inline _LIBCPP_HIDE_FROM_ABI3229__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >3230pow(const typename _Expr::value_type& __x, const _Expr& __y) {3231  typedef typename _Expr::value_type value_type;3232  typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;3233  return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));3234}3235 3236template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3237inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >3238sin(const _Expr& __x) {3239  typedef typename _Expr::value_type value_type;3240  typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;3241  return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));3242}3243 3244template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3245inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >3246sinh(const _Expr& __x) {3247  typedef typename _Expr::value_type value_type;3248  typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;3249  return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));3250}3251 3252template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3253inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >3254sqrt(const _Expr& __x) {3255  typedef typename _Expr::value_type value_type;3256  typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;3257  return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));3258}3259 3260template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3261inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >3262tan(const _Expr& __x) {3263  typedef typename _Expr::value_type value_type;3264  typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;3265  return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));3266}3267 3268template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>3269inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >3270tanh(const _Expr& __x) {3271  typedef typename _Expr::value_type value_type;3272  typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;3273  return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));3274}3275 3276template <class _Tp>3277inline _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v) {3278  return __v.__begin_;3279}3280 3281template <class _Tp>3282inline _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v) {3283  return __v.__begin_;3284}3285 3286template <class _Tp>3287inline _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v) {3288  return __v.__end_;3289}3290 3291template <class _Tp>3292inline _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v) {3293  return __v.__end_;3294}3295 3296_LIBCPP_END_NAMESPACE_STD3297 3298_LIBCPP_POP_MACROS3299 3300#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 203301#    include <algorithm>3302#    include <concepts>3303#    include <cstdlib>3304#    include <cstring>3305#    include <functional>3306#    include <stdexcept>3307#    include <type_traits>3308#  endif3309#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)3310 3311#endif // _LIBCPP_VALARRAY3312