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-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_VALARRAY 11#define _LIBCPP_VALARRAY 12 13/* 14 valarray synopsis 15 16namespace std 17{ 18 19template<class T> 20class valarray 21{ 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 slice 111{ 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++20 121}; 122 123template <class T> 124class slice_array 125{ 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 gslice 149{ 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_array 162{ 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_array 188{ 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_array 214{ 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} // std 343 344*/ 345 346#include <__algorithm/copy.h> 347#include <__algorithm/count.h> 348#include <__algorithm/fill.h> 349#include <__algorithm/max_element.h> 350#include <__algorithm/min.h> 351#include <__algorithm/min_element.h> 352#include <__algorithm/unwrap_iter.h> 353#include <__assert> // all public C++ headers provide the assertion handler 354#include <__config> 355#include <__functional/operations.h> 356#include <__memory/addressof.h> 357#include <__memory/allocator.h> 358#include <__memory/uninitialized_algorithms.h> 359#include <__type_traits/decay.h> 360#include <__type_traits/remove_reference.h> 361#include <__utility/move.h> 362#include <__utility/swap.h> 363#include <cmath> 364#include <cstddef> 365#include <new> 366#include <version> 367 368// standard-mandated includes 369 370// [valarray.syn] 371#include <initializer_list> 372 373#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 374# pragma GCC system_header 375#endif 376 377_LIBCPP_PUSH_MACROS 378#include <__undef_macros> 379 380_LIBCPP_BEGIN_NAMESPACE_STD 381 382template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray; 383 384class _LIBCPP_TEMPLATE_VIS slice 385{ 386 size_t __start_; 387 size_t __size_; 388 size_t __stride_; 389public: 390 _LIBCPP_HIDE_FROM_ABI 391 slice() 392 : __start_(0), 393 __size_(0), 394 __stride_(0) 395 {} 396 397 _LIBCPP_HIDE_FROM_ABI 398 slice(size_t __start, size_t __size, size_t __stride) 399 : __start_(__start), 400 __size_(__size), 401 __stride_(__stride) 402 {} 403 404 _LIBCPP_HIDE_FROM_ABI size_t start() const {return __start_;} 405 _LIBCPP_HIDE_FROM_ABI size_t size() const {return __size_;} 406 _LIBCPP_HIDE_FROM_ABI size_t stride() const {return __stride_;} 407 408#if _LIBCPP_STD_VER >= 20 409 410 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) { 411 return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride(); 412 } 413 414#endif 415}; 416 417template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array; 418class _LIBCPP_EXPORTED_FROM_ABI gslice; 419template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array; 420template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array; 421template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array; 422 423template <class _Tp> 424_LIBCPP_HIDE_FROM_ABI 425_Tp* 426begin(valarray<_Tp>& __v); 427 428template <class _Tp> 429_LIBCPP_HIDE_FROM_ABI 430const _Tp* 431begin(const valarray<_Tp>& __v); 432 433template <class _Tp> 434_LIBCPP_HIDE_FROM_ABI 435_Tp* 436end(valarray<_Tp>& __v); 437 438template <class _Tp> 439_LIBCPP_HIDE_FROM_ABI 440const _Tp* 441end(const valarray<_Tp>& __v); 442 443template <class _Op, class _A0> 444struct _UnaryOp 445{ 446 typedef typename _Op::__result_type __result_type; 447 using value_type = __decay_t<__result_type>; 448 449 _Op __op_; 450 _A0 __a0_; 451 452 _LIBCPP_HIDE_FROM_ABI 453 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {} 454 455 _LIBCPP_HIDE_FROM_ABI 456 __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} 457 458 _LIBCPP_HIDE_FROM_ABI 459 size_t size() const {return __a0_.size();} 460}; 461 462template <class _Op, class _A0, class _A1> 463struct _BinaryOp 464{ 465 typedef typename _Op::__result_type __result_type; 466 using value_type = __decay_t<__result_type>; 467 468 _Op __op_; 469 _A0 __a0_; 470 _A1 __a1_; 471 472 _LIBCPP_HIDE_FROM_ABI 473 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1) 474 : __op_(__op), __a0_(__a0), __a1_(__a1) {} 475 476 _LIBCPP_HIDE_FROM_ABI 477 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} 478 479 _LIBCPP_HIDE_FROM_ABI 480 size_t size() const {return __a0_.size();} 481}; 482 483template <class _Tp> 484class __scalar_expr 485{ 486public: 487 typedef _Tp value_type; 488 typedef const _Tp& __result_type; 489private: 490 const value_type& __t_; 491 size_t __s_; 492public: 493 _LIBCPP_HIDE_FROM_ABI 494 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {} 495 496 _LIBCPP_HIDE_FROM_ABI 497 __result_type operator[](size_t) const {return __t_;} 498 499 _LIBCPP_HIDE_FROM_ABI 500 size_t size() const {return __s_;} 501}; 502 503template <class _Tp> 504struct __unary_plus 505{ 506 typedef _Tp __result_type; 507 _LIBCPP_HIDE_FROM_ABI 508 _Tp operator()(const _Tp& __x) const 509 {return +__x;} 510}; 511 512template <class _Tp> 513struct __bit_not 514{ 515 typedef _Tp __result_type; 516 _LIBCPP_HIDE_FROM_ABI 517 _Tp operator()(const _Tp& __x) const 518 {return ~__x;} 519}; 520 521template <class _Tp> 522struct __bit_shift_left 523{ 524 typedef _Tp __result_type; 525 _LIBCPP_HIDE_FROM_ABI 526 _Tp operator()(const _Tp& __x, const _Tp& __y) const 527 {return __x << __y;} 528}; 529 530template <class _Tp> 531struct __bit_shift_right 532{ 533 typedef _Tp __result_type; 534 _LIBCPP_HIDE_FROM_ABI 535 _Tp operator()(const _Tp& __x, const _Tp& __y) const 536 {return __x >> __y;} 537}; 538 539template <class _Tp, class _Fp> 540struct __apply_expr 541{ 542private: 543 _Fp __f_; 544public: 545 typedef _Tp __result_type; 546 547 _LIBCPP_HIDE_FROM_ABI 548 explicit __apply_expr(_Fp __f) : __f_(__f) {} 549 550 _LIBCPP_HIDE_FROM_ABI 551 _Tp operator()(const _Tp& __x) const 552 {return __f_(__x);} 553}; 554 555template <class _Tp> 556struct __abs_expr 557{ 558 typedef _Tp __result_type; 559 _LIBCPP_HIDE_FROM_ABI 560 _Tp operator()(const _Tp& __x) const 561 {return std::abs(__x);} 562}; 563 564template <class _Tp> 565struct __acos_expr 566{ 567 typedef _Tp __result_type; 568 _LIBCPP_HIDE_FROM_ABI 569 _Tp operator()(const _Tp& __x) const 570 {return std::acos(__x);} 571}; 572 573template <class _Tp> 574struct __asin_expr 575{ 576 typedef _Tp __result_type; 577 _LIBCPP_HIDE_FROM_ABI 578 _Tp operator()(const _Tp& __x) const 579 {return std::asin(__x);} 580}; 581 582template <class _Tp> 583struct __atan_expr 584{ 585 typedef _Tp __result_type; 586 _LIBCPP_HIDE_FROM_ABI 587 _Tp operator()(const _Tp& __x) const 588 {return std::atan(__x);} 589}; 590 591template <class _Tp> 592struct __atan2_expr 593{ 594 typedef _Tp __result_type; 595 _LIBCPP_HIDE_FROM_ABI 596 _Tp operator()(const _Tp& __x, const _Tp& __y) const 597 {return std::atan2(__x, __y);} 598}; 599 600template <class _Tp> 601struct __cos_expr 602{ 603 typedef _Tp __result_type; 604 _LIBCPP_HIDE_FROM_ABI 605 _Tp operator()(const _Tp& __x) const 606 {return std::cos(__x);} 607}; 608 609template <class _Tp> 610struct __cosh_expr 611{ 612 typedef _Tp __result_type; 613 _LIBCPP_HIDE_FROM_ABI 614 _Tp operator()(const _Tp& __x) const 615 {return std::cosh(__x);} 616}; 617 618template <class _Tp> 619struct __exp_expr 620{ 621 typedef _Tp __result_type; 622 _LIBCPP_HIDE_FROM_ABI 623 _Tp operator()(const _Tp& __x) const 624 {return std::exp(__x);} 625}; 626 627template <class _Tp> 628struct __log_expr 629{ 630 typedef _Tp __result_type; 631 _LIBCPP_HIDE_FROM_ABI 632 _Tp operator()(const _Tp& __x) const 633 {return std::log(__x);} 634}; 635 636template <class _Tp> 637struct __log10_expr 638{ 639 typedef _Tp __result_type; 640 _LIBCPP_HIDE_FROM_ABI 641 _Tp operator()(const _Tp& __x) const 642 {return std::log10(__x);} 643}; 644 645template <class _Tp> 646struct __pow_expr 647{ 648 typedef _Tp __result_type; 649 _LIBCPP_HIDE_FROM_ABI 650 _Tp operator()(const _Tp& __x, const _Tp& __y) const 651 {return std::pow(__x, __y);} 652}; 653 654template <class _Tp> 655struct __sin_expr 656{ 657 typedef _Tp __result_type; 658 _LIBCPP_HIDE_FROM_ABI 659 _Tp operator()(const _Tp& __x) const 660 {return std::sin(__x);} 661}; 662 663template <class _Tp> 664struct __sinh_expr 665{ 666 typedef _Tp __result_type; 667 _LIBCPP_HIDE_FROM_ABI 668 _Tp operator()(const _Tp& __x) const 669 {return std::sinh(__x);} 670}; 671 672template <class _Tp> 673struct __sqrt_expr 674{ 675 typedef _Tp __result_type; 676 _LIBCPP_HIDE_FROM_ABI 677 _Tp operator()(const _Tp& __x) const 678 {return std::sqrt(__x);} 679}; 680 681template <class _Tp> 682struct __tan_expr 683{ 684 typedef _Tp __result_type; 685 _LIBCPP_HIDE_FROM_ABI 686 _Tp operator()(const _Tp& __x) const 687 {return std::tan(__x);} 688}; 689 690template <class _Tp> 691struct __tanh_expr 692{ 693 typedef _Tp __result_type; 694 _LIBCPP_HIDE_FROM_ABI 695 _Tp operator()(const _Tp& __x) const 696 {return std::tanh(__x);} 697}; 698 699template <class _ValExpr> 700class __slice_expr 701{ 702 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; 703public: 704 typedef typename _RmExpr::value_type value_type; 705 typedef value_type __result_type; 706 707private: 708 _ValExpr __expr_; 709 size_t __start_; 710 size_t __size_; 711 size_t __stride_; 712 713 _LIBCPP_HIDE_FROM_ABI 714 __slice_expr(const slice& __sl, const _RmExpr& __e) 715 : __expr_(__e), 716 __start_(__sl.start()), 717 __size_(__sl.size()), 718 __stride_(__sl.stride()) 719 {} 720public: 721 722 _LIBCPP_HIDE_FROM_ABI 723 __result_type operator[](size_t __i) const 724 {return __expr_[__start_ + __i * __stride_];} 725 726 _LIBCPP_HIDE_FROM_ABI 727 size_t size() const {return __size_;} 728 729 template <class> friend class __val_expr; 730 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; 731}; 732 733template <class _ValExpr> 734class __mask_expr; 735 736template <class _ValExpr> 737class __indirect_expr; 738 739template <class _ValExpr> 740class __shift_expr 741{ 742 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; 743public: 744 typedef typename _RmExpr::value_type value_type; 745 typedef value_type __result_type; 746 747private: 748 _ValExpr __expr_; 749 size_t __size_; 750 ptrdiff_t __ul_; 751 ptrdiff_t __sn_; 752 ptrdiff_t __n_; 753 static const ptrdiff_t _Np = static_cast<ptrdiff_t>( 754 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1); 755 756 _LIBCPP_HIDE_FROM_ABI 757 __shift_expr(int __n, const _RmExpr& __e) 758 : __expr_(__e), 759 __size_(__e.size()), 760 __n_(__n) 761 { 762 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np); 763 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np); 764 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n); 765 } 766public: 767 768 _LIBCPP_HIDE_FROM_ABI 769 __result_type operator[](size_t __j) const 770 { 771 ptrdiff_t __i = static_cast<ptrdiff_t>(__j); 772 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np; 773 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m); 774 } 775 776 _LIBCPP_HIDE_FROM_ABI 777 size_t size() const {return __size_;} 778 779 template <class> friend class __val_expr; 780}; 781 782template <class _ValExpr> 783class __cshift_expr 784{ 785 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; 786public: 787 typedef typename _RmExpr::value_type value_type; 788 typedef value_type __result_type; 789 790private: 791 _ValExpr __expr_; 792 size_t __size_; 793 size_t __m_; 794 size_t __o1_; 795 size_t __o2_; 796 797 _LIBCPP_HIDE_FROM_ABI 798 __cshift_expr(int __n, const _RmExpr& __e) 799 : __expr_(__e), 800 __size_(__e.size()) 801 { 802 __n %= static_cast<int>(__size_); 803 if (__n >= 0) 804 { 805 __m_ = __size_ - __n; 806 __o1_ = __n; 807 __o2_ = __n - __size_; 808 } 809 else 810 { 811 __m_ = -__n; 812 __o1_ = __n + __size_; 813 __o2_ = __n; 814 } 815 } 816public: 817 818 _LIBCPP_HIDE_FROM_ABI 819 __result_type operator[](size_t __i) const 820 { 821 if (__i < __m_) 822 return __expr_[__i + __o1_]; 823 return __expr_[__i + __o2_]; 824 } 825 826 _LIBCPP_HIDE_FROM_ABI 827 size_t size() const {return __size_;} 828 829 template <class> friend class __val_expr; 830}; 831 832template<class _ValExpr> 833class __val_expr; 834 835template<class _ValExpr> 836struct __is_val_expr : false_type {}; 837 838template<class _ValExpr> 839struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; 840 841template<class _Tp> 842struct __is_val_expr<valarray<_Tp> > : true_type {}; 843 844template<class _Tp> 845class _LIBCPP_TEMPLATE_VIS valarray 846{ 847public: 848 typedef _Tp value_type; 849 typedef _Tp __result_type; 850 851private: 852 value_type* __begin_; 853 value_type* __end_; 854 855public: 856 // construct/destroy: 857 _LIBCPP_HIDE_FROM_ABI 858 valarray() : __begin_(nullptr), __end_(nullptr) {} 859 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 860 explicit valarray(size_t __n); 861 _LIBCPP_HIDE_FROM_ABI 862 valarray(const value_type& __x, size_t __n); 863 valarray(const value_type* __p, size_t __n); 864 valarray(const valarray& __v); 865#ifndef _LIBCPP_CXX03_LANG 866 _LIBCPP_HIDE_FROM_ABI 867 valarray(valarray&& __v) _NOEXCEPT; 868 valarray(initializer_list<value_type> __il); 869#endif // _LIBCPP_CXX03_LANG 870 valarray(const slice_array<value_type>& __sa); 871 valarray(const gslice_array<value_type>& __ga); 872 valarray(const mask_array<value_type>& __ma); 873 valarray(const indirect_array<value_type>& __ia); 874 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 875 ~valarray(); 876 877 // assignment: 878 valarray& operator=(const valarray& __v); 879#ifndef _LIBCPP_CXX03_LANG 880 _LIBCPP_HIDE_FROM_ABI 881 valarray& operator=(valarray&& __v) _NOEXCEPT; 882 _LIBCPP_HIDE_FROM_ABI 883 valarray& operator=(initializer_list<value_type>); 884#endif // _LIBCPP_CXX03_LANG 885 _LIBCPP_HIDE_FROM_ABI 886 valarray& operator=(const value_type& __x); 887 _LIBCPP_HIDE_FROM_ABI 888 valarray& operator=(const slice_array<value_type>& __sa); 889 _LIBCPP_HIDE_FROM_ABI 890 valarray& operator=(const gslice_array<value_type>& __ga); 891 _LIBCPP_HIDE_FROM_ABI 892 valarray& operator=(const mask_array<value_type>& __ma); 893 _LIBCPP_HIDE_FROM_ABI 894 valarray& operator=(const indirect_array<value_type>& __ia); 895 template <class _ValExpr> 896 _LIBCPP_HIDE_FROM_ABI 897 valarray& operator=(const __val_expr<_ValExpr>& __v); 898 899 // element access: 900 _LIBCPP_HIDE_FROM_ABI 901 const value_type& operator[](size_t __i) const {return __begin_[__i];} 902 903 _LIBCPP_HIDE_FROM_ABI 904 value_type& operator[](size_t __i) {return __begin_[__i];} 905 906 // subset operations: 907 _LIBCPP_HIDE_FROM_ABI 908 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; 909 _LIBCPP_HIDE_FROM_ABI 910 slice_array<value_type> operator[](slice __s); 911 _LIBCPP_HIDE_FROM_ABI 912 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const; 913 _LIBCPP_HIDE_FROM_ABI 914 gslice_array<value_type> operator[](const gslice& __gs); 915#ifndef _LIBCPP_CXX03_LANG 916 _LIBCPP_HIDE_FROM_ABI 917 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const; 918 _LIBCPP_HIDE_FROM_ABI 919 gslice_array<value_type> operator[](gslice&& __gs); 920#endif // _LIBCPP_CXX03_LANG 921 _LIBCPP_HIDE_FROM_ABI 922 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; 923 _LIBCPP_HIDE_FROM_ABI 924 mask_array<value_type> operator[](const valarray<bool>& __vb); 925#ifndef _LIBCPP_CXX03_LANG 926 _LIBCPP_HIDE_FROM_ABI 927 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const; 928 _LIBCPP_HIDE_FROM_ABI 929 mask_array<value_type> operator[](valarray<bool>&& __vb); 930#endif // _LIBCPP_CXX03_LANG 931 _LIBCPP_HIDE_FROM_ABI 932 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; 933 _LIBCPP_HIDE_FROM_ABI 934 indirect_array<value_type> operator[](const valarray<size_t>& __vs); 935#ifndef _LIBCPP_CXX03_LANG 936 _LIBCPP_HIDE_FROM_ABI 937 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const; 938 _LIBCPP_HIDE_FROM_ABI 939 indirect_array<value_type> operator[](valarray<size_t>&& __vs); 940#endif // _LIBCPP_CXX03_LANG 941 942 // unary operators: 943 _LIBCPP_HIDE_FROM_ABI 944 __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const; 945 _LIBCPP_HIDE_FROM_ABI 946 __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const; 947 _LIBCPP_HIDE_FROM_ABI 948 __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const; 949 _LIBCPP_HIDE_FROM_ABI 950 __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const; 951 952 // computed assignment: 953 _LIBCPP_HIDE_FROM_ABI 954 valarray& operator*= (const value_type& __x); 955 _LIBCPP_HIDE_FROM_ABI 956 valarray& operator/= (const value_type& __x); 957 _LIBCPP_HIDE_FROM_ABI 958 valarray& operator%= (const value_type& __x); 959 _LIBCPP_HIDE_FROM_ABI 960 valarray& operator+= (const value_type& __x); 961 _LIBCPP_HIDE_FROM_ABI 962 valarray& operator-= (const value_type& __x); 963 _LIBCPP_HIDE_FROM_ABI 964 valarray& operator^= (const value_type& __x); 965 _LIBCPP_HIDE_FROM_ABI 966 valarray& operator&= (const value_type& __x); 967 _LIBCPP_HIDE_FROM_ABI 968 valarray& operator|= (const value_type& __x); 969 _LIBCPP_HIDE_FROM_ABI 970 valarray& operator<<=(const value_type& __x); 971 _LIBCPP_HIDE_FROM_ABI 972 valarray& operator>>=(const value_type& __x); 973 974 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 975 _LIBCPP_HIDE_FROM_ABI valarray& 976 operator*= (const _Expr& __v); 977 978 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 979 _LIBCPP_HIDE_FROM_ABI valarray& 980 operator/= (const _Expr& __v); 981 982 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 983 _LIBCPP_HIDE_FROM_ABI valarray& 984 operator%= (const _Expr& __v); 985 986 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 987 _LIBCPP_HIDE_FROM_ABI valarray& 988 operator+= (const _Expr& __v); 989 990 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 991 _LIBCPP_HIDE_FROM_ABI valarray& 992 operator-= (const _Expr& __v); 993 994 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 995 _LIBCPP_HIDE_FROM_ABI valarray& 996 operator^= (const _Expr& __v); 997 998 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 999 _LIBCPP_HIDE_FROM_ABI valarray& 1000 operator|= (const _Expr& __v); 1001 1002 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1003 _LIBCPP_HIDE_FROM_ABI valarray& 1004 operator&= (const _Expr& __v); 1005 1006 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1007 _LIBCPP_HIDE_FROM_ABI valarray& 1008 operator<<= (const _Expr& __v); 1009 1010 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1011 _LIBCPP_HIDE_FROM_ABI valarray& 1012 operator>>= (const _Expr& __v); 1013 1014 // member functions: 1015 _LIBCPP_HIDE_FROM_ABI 1016 void swap(valarray& __v) _NOEXCEPT; 1017 1018 _LIBCPP_HIDE_FROM_ABI 1019 size_t size() const {return static_cast<size_t>(__end_ - __begin_);} 1020 1021 _LIBCPP_HIDE_FROM_ABI 1022 value_type sum() const; 1023 _LIBCPP_HIDE_FROM_ABI 1024 value_type min() const; 1025 _LIBCPP_HIDE_FROM_ABI 1026 value_type max() const; 1027 1028 valarray shift (int __i) const; 1029 valarray cshift(int __i) const; 1030 valarray apply(value_type __f(value_type)) const; 1031 valarray apply(value_type __f(const value_type&)) const; 1032 void resize(size_t __n, value_type __x = value_type()); 1033 1034private: 1035 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; 1036 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array; 1037 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array; 1038 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array; 1039 template <class> friend class __mask_expr; 1040 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array; 1041 template <class> friend class __indirect_expr; 1042 template <class> friend class __val_expr; 1043 1044 template <class _Up> 1045 friend 1046 _Up* 1047 begin(valarray<_Up>& __v); 1048 1049 template <class _Up> 1050 friend 1051 const _Up* 1052 begin(const valarray<_Up>& __v); 1053 1054 template <class _Up> 1055 friend 1056 _Up* 1057 end(valarray<_Up>& __v); 1058 1059 template <class _Up> 1060 friend 1061 const _Up* 1062 end(const valarray<_Up>& __v); 1063 1064 _LIBCPP_HIDE_FROM_ABI 1065 void __clear(size_t __capacity); 1066 valarray& __assign_range(const value_type* __f, const value_type* __l); 1067}; 1068 1069#if _LIBCPP_STD_VER >= 17 1070template<class _Tp, size_t _Size> 1071valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>; 1072#endif 1073 1074extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t); 1075 1076template <class _Op, class _Tp> 1077struct _UnaryOp<_Op, valarray<_Tp> > 1078{ 1079 typedef typename _Op::__result_type __result_type; 1080 using value_type = __decay_t<__result_type>; 1081 1082 _Op __op_; 1083 const valarray<_Tp>& __a0_; 1084 1085 _LIBCPP_HIDE_FROM_ABI 1086 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {} 1087 1088 _LIBCPP_HIDE_FROM_ABI 1089 __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} 1090 1091 _LIBCPP_HIDE_FROM_ABI 1092 size_t size() const {return __a0_.size();} 1093}; 1094 1095template <class _Op, class _Tp, class _A1> 1096struct _BinaryOp<_Op, valarray<_Tp>, _A1> 1097{ 1098 typedef typename _Op::__result_type __result_type; 1099 using value_type = __decay_t<__result_type>; 1100 1101 _Op __op_; 1102 const valarray<_Tp>& __a0_; 1103 _A1 __a1_; 1104 1105 _LIBCPP_HIDE_FROM_ABI 1106 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1) 1107 : __op_(__op), __a0_(__a0), __a1_(__a1) {} 1108 1109 _LIBCPP_HIDE_FROM_ABI 1110 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} 1111 1112 _LIBCPP_HIDE_FROM_ABI 1113 size_t size() const {return __a0_.size();} 1114}; 1115 1116template <class _Op, class _A0, class _Tp> 1117struct _BinaryOp<_Op, _A0, valarray<_Tp> > 1118{ 1119 typedef typename _Op::__result_type __result_type; 1120 using value_type = __decay_t<__result_type>; 1121 1122 _Op __op_; 1123 _A0 __a0_; 1124 const valarray<_Tp>& __a1_; 1125 1126 _LIBCPP_HIDE_FROM_ABI 1127 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1) 1128 : __op_(__op), __a0_(__a0), __a1_(__a1) {} 1129 1130 _LIBCPP_HIDE_FROM_ABI 1131 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} 1132 1133 _LIBCPP_HIDE_FROM_ABI 1134 size_t size() const {return __a0_.size();} 1135}; 1136 1137template <class _Op, class _Tp> 1138struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > 1139{ 1140 typedef typename _Op::__result_type __result_type; 1141 using value_type = __decay_t<__result_type>; 1142 1143 _Op __op_; 1144 const valarray<_Tp>& __a0_; 1145 const valarray<_Tp>& __a1_; 1146 1147 _LIBCPP_HIDE_FROM_ABI 1148 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1) 1149 : __op_(__op), __a0_(__a0), __a1_(__a1) {} 1150 1151 _LIBCPP_HIDE_FROM_ABI 1152 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} 1153 1154 _LIBCPP_HIDE_FROM_ABI 1155 size_t size() const {return __a0_.size();} 1156}; 1157 1158// slice_array 1159 1160template <class _Tp> 1161class _LIBCPP_TEMPLATE_VIS slice_array 1162{ 1163public: 1164 typedef _Tp value_type; 1165 1166private: 1167 value_type* __vp_; 1168 size_t __size_; 1169 size_t __stride_; 1170 1171public: 1172 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1173 void 1174 _LIBCPP_HIDE_FROM_ABI 1175 operator=(const _Expr& __v) const; 1176 1177 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1178 void 1179 _LIBCPP_HIDE_FROM_ABI 1180 operator*=(const _Expr& __v) const; 1181 1182 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1183 void 1184 _LIBCPP_HIDE_FROM_ABI 1185 operator/=(const _Expr& __v) const; 1186 1187 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1188 void 1189 _LIBCPP_HIDE_FROM_ABI 1190 operator%=(const _Expr& __v) const; 1191 1192 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1193 void 1194 _LIBCPP_HIDE_FROM_ABI 1195 operator+=(const _Expr& __v) const; 1196 1197 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1198 void 1199 _LIBCPP_HIDE_FROM_ABI 1200 operator-=(const _Expr& __v) const; 1201 1202 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1203 void 1204 _LIBCPP_HIDE_FROM_ABI 1205 operator^=(const _Expr& __v) const; 1206 1207 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1208 void 1209 _LIBCPP_HIDE_FROM_ABI 1210 operator&=(const _Expr& __v) const; 1211 1212 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1213 void 1214 _LIBCPP_HIDE_FROM_ABI 1215 operator|=(const _Expr& __v) const; 1216 1217 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1218 void 1219 _LIBCPP_HIDE_FROM_ABI 1220 operator<<=(const _Expr& __v) const; 1221 1222 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1223 void 1224 _LIBCPP_HIDE_FROM_ABI 1225 operator>>=(const _Expr& __v) const; 1226 1227 slice_array(slice_array const&) = default; 1228 1229 _LIBCPP_HIDE_FROM_ABI 1230 const slice_array& operator=(const slice_array& __sa) const; 1231 1232 _LIBCPP_HIDE_FROM_ABI 1233 void operator=(const value_type& __x) const; 1234 1235 _LIBCPP_HIDE_FROM_ABI 1236 void operator=(const valarray<value_type>& __va) const; 1237 1238private: 1239 _LIBCPP_HIDE_FROM_ABI 1240 slice_array(const slice& __sl, const valarray<value_type>& __v) 1241 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), 1242 __size_(__sl.size()), 1243 __stride_(__sl.stride()) 1244 {} 1245 1246 template <class> friend class valarray; 1247}; 1248 1249template <class _Tp> 1250inline 1251const slice_array<_Tp>& 1252slice_array<_Tp>::operator=(const slice_array& __sa) const 1253{ 1254 value_type* __t = __vp_; 1255 const value_type* __s = __sa.__vp_; 1256 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_) 1257 *__t = *__s; 1258 return *this; 1259} 1260 1261template <class _Tp> 1262template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1263inline 1264void 1265slice_array<_Tp>::operator=(const _Expr& __v) const 1266{ 1267 value_type* __t = __vp_; 1268 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1269 *__t = __v[__i]; 1270} 1271 1272template <class _Tp> 1273inline void 1274slice_array<_Tp>::operator=(const valarray<value_type>& __va) const 1275{ 1276 value_type* __t = __vp_; 1277 for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_) 1278 *__t = __va[__i]; 1279} 1280 1281template <class _Tp> 1282template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1283inline 1284void 1285slice_array<_Tp>::operator*=(const _Expr& __v) const 1286{ 1287 value_type* __t = __vp_; 1288 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1289 *__t *= __v[__i]; 1290} 1291 1292template <class _Tp> 1293template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1294inline 1295void 1296slice_array<_Tp>::operator/=(const _Expr& __v) const 1297{ 1298 value_type* __t = __vp_; 1299 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1300 *__t /= __v[__i]; 1301} 1302 1303template <class _Tp> 1304template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1305inline 1306void 1307slice_array<_Tp>::operator%=(const _Expr& __v) const 1308{ 1309 value_type* __t = __vp_; 1310 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1311 *__t %= __v[__i]; 1312} 1313 1314template <class _Tp> 1315template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1316inline 1317void 1318slice_array<_Tp>::operator+=(const _Expr& __v) const 1319{ 1320 value_type* __t = __vp_; 1321 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1322 *__t += __v[__i]; 1323} 1324 1325template <class _Tp> 1326template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1327inline 1328void 1329slice_array<_Tp>::operator-=(const _Expr& __v) const 1330{ 1331 value_type* __t = __vp_; 1332 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1333 *__t -= __v[__i]; 1334} 1335 1336template <class _Tp> 1337template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1338inline 1339void 1340slice_array<_Tp>::operator^=(const _Expr& __v) const 1341{ 1342 value_type* __t = __vp_; 1343 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1344 *__t ^= __v[__i]; 1345} 1346 1347template <class _Tp> 1348template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1349inline 1350void 1351slice_array<_Tp>::operator&=(const _Expr& __v) const 1352{ 1353 value_type* __t = __vp_; 1354 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1355 *__t &= __v[__i]; 1356} 1357 1358template <class _Tp> 1359template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1360inline 1361void 1362slice_array<_Tp>::operator|=(const _Expr& __v) const 1363{ 1364 value_type* __t = __vp_; 1365 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1366 *__t |= __v[__i]; 1367} 1368 1369template <class _Tp> 1370template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1371inline 1372void 1373slice_array<_Tp>::operator<<=(const _Expr& __v) const 1374{ 1375 value_type* __t = __vp_; 1376 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1377 *__t <<= __v[__i]; 1378} 1379 1380template <class _Tp> 1381template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1382inline 1383void 1384slice_array<_Tp>::operator>>=(const _Expr& __v) const 1385{ 1386 value_type* __t = __vp_; 1387 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1388 *__t >>= __v[__i]; 1389} 1390 1391template <class _Tp> 1392inline 1393void 1394slice_array<_Tp>::operator=(const value_type& __x) const 1395{ 1396 value_type* __t = __vp_; 1397 for (size_t __n = __size_; __n; --__n, __t += __stride_) 1398 *__t = __x; 1399} 1400 1401// gslice 1402 1403class _LIBCPP_EXPORTED_FROM_ABI gslice 1404{ 1405 valarray<size_t> __size_; 1406 valarray<size_t> __stride_; 1407 valarray<size_t> __1d_; 1408 1409public: 1410 _LIBCPP_HIDE_FROM_ABI 1411 gslice() {} 1412 1413 _LIBCPP_HIDE_FROM_ABI 1414 gslice(size_t __start, const valarray<size_t>& __size, 1415 const valarray<size_t>& __stride) 1416 : __size_(__size), 1417 __stride_(__stride) 1418 {__init(__start);} 1419 1420#ifndef _LIBCPP_CXX03_LANG 1421 1422 _LIBCPP_HIDE_FROM_ABI 1423 gslice(size_t __start, const valarray<size_t>& __size, 1424 valarray<size_t>&& __stride) 1425 : __size_(__size), 1426 __stride_(std::move(__stride)) 1427 {__init(__start);} 1428 1429 _LIBCPP_HIDE_FROM_ABI 1430 gslice(size_t __start, valarray<size_t>&& __size, 1431 const valarray<size_t>& __stride) 1432 : __size_(std::move(__size)), 1433 __stride_(__stride) 1434 {__init(__start);} 1435 1436 _LIBCPP_HIDE_FROM_ABI 1437 gslice(size_t __start, valarray<size_t>&& __size, 1438 valarray<size_t>&& __stride) 1439 : __size_(std::move(__size)), 1440 __stride_(std::move(__stride)) 1441 {__init(__start);} 1442 1443#endif // _LIBCPP_CXX03_LANG 1444 1445 _LIBCPP_HIDE_FROM_ABI 1446 size_t start() const {return __1d_.size() ? __1d_[0] : 0;} 1447 1448 _LIBCPP_HIDE_FROM_ABI 1449 valarray<size_t> size() const {return __size_;} 1450 1451 _LIBCPP_HIDE_FROM_ABI 1452 valarray<size_t> stride() const {return __stride_;} 1453 1454private: 1455 void __init(size_t __start); 1456 1457 template <class> friend class gslice_array; 1458 template <class> friend class valarray; 1459 template <class> friend class __val_expr; 1460}; 1461 1462// gslice_array 1463 1464template <class _Tp> 1465class _LIBCPP_TEMPLATE_VIS gslice_array 1466{ 1467public: 1468 typedef _Tp value_type; 1469 1470private: 1471 value_type* __vp_; 1472 valarray<size_t> __1d_; 1473 1474public: 1475 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1476 void 1477 _LIBCPP_HIDE_FROM_ABI 1478 operator=(const _Expr& __v) const; 1479 1480 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1481 void 1482 _LIBCPP_HIDE_FROM_ABI 1483 operator*=(const _Expr& __v) const; 1484 1485 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1486 void 1487 _LIBCPP_HIDE_FROM_ABI 1488 operator/=(const _Expr& __v) const; 1489 1490 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1491 void 1492 _LIBCPP_HIDE_FROM_ABI 1493 operator%=(const _Expr& __v) const; 1494 1495 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1496 void 1497 _LIBCPP_HIDE_FROM_ABI 1498 operator+=(const _Expr& __v) const; 1499 1500 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1501 void 1502 _LIBCPP_HIDE_FROM_ABI 1503 operator-=(const _Expr& __v) const; 1504 1505 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1506 void 1507 _LIBCPP_HIDE_FROM_ABI 1508 operator^=(const _Expr& __v) const; 1509 1510 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1511 void 1512 _LIBCPP_HIDE_FROM_ABI 1513 operator&=(const _Expr& __v) const; 1514 1515 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1516 void 1517 _LIBCPP_HIDE_FROM_ABI 1518 operator|=(const _Expr& __v) const; 1519 1520 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1521 void 1522 _LIBCPP_HIDE_FROM_ABI 1523 operator<<=(const _Expr& __v) const; 1524 1525 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1526 void 1527 _LIBCPP_HIDE_FROM_ABI 1528 operator>>=(const _Expr& __v) const; 1529 1530 _LIBCPP_HIDE_FROM_ABI 1531 const gslice_array& operator=(const gslice_array& __ga) const; 1532 1533 _LIBCPP_HIDE_FROM_ABI 1534 void operator=(const value_type& __x) const; 1535 1536 gslice_array(const gslice_array&) = default; 1537 1538private: 1539 gslice_array(const gslice& __gs, const valarray<value_type>& __v) 1540 : __vp_(const_cast<value_type*>(__v.__begin_)), 1541 __1d_(__gs.__1d_) 1542 {} 1543 1544#ifndef _LIBCPP_CXX03_LANG 1545 gslice_array(gslice&& __gs, const valarray<value_type>& __v) 1546 : __vp_(const_cast<value_type*>(__v.__begin_)), 1547 __1d_(std::move(__gs.__1d_)) 1548 {} 1549#endif // _LIBCPP_CXX03_LANG 1550 1551 template <class> friend class valarray; 1552}; 1553 1554template <class _Tp> 1555template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1556inline 1557void 1558gslice_array<_Tp>::operator=(const _Expr& __v) const 1559{ 1560 typedef const size_t* _Ip; 1561 size_t __j = 0; 1562 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1563 __vp_[*__i] = __v[__j]; 1564} 1565 1566template <class _Tp> 1567template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1568inline 1569void 1570gslice_array<_Tp>::operator*=(const _Expr& __v) const 1571{ 1572 typedef const size_t* _Ip; 1573 size_t __j = 0; 1574 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1575 __vp_[*__i] *= __v[__j]; 1576} 1577 1578template <class _Tp> 1579template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1580inline 1581void 1582gslice_array<_Tp>::operator/=(const _Expr& __v) const 1583{ 1584 typedef const size_t* _Ip; 1585 size_t __j = 0; 1586 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1587 __vp_[*__i] /= __v[__j]; 1588} 1589 1590template <class _Tp> 1591template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1592inline 1593void 1594gslice_array<_Tp>::operator%=(const _Expr& __v) const 1595{ 1596 typedef const size_t* _Ip; 1597 size_t __j = 0; 1598 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1599 __vp_[*__i] %= __v[__j]; 1600} 1601 1602template <class _Tp> 1603template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1604inline 1605void 1606gslice_array<_Tp>::operator+=(const _Expr& __v) const 1607{ 1608 typedef const size_t* _Ip; 1609 size_t __j = 0; 1610 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1611 __vp_[*__i] += __v[__j]; 1612} 1613 1614template <class _Tp> 1615template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1616inline 1617void 1618gslice_array<_Tp>::operator-=(const _Expr& __v) const 1619{ 1620 typedef const size_t* _Ip; 1621 size_t __j = 0; 1622 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1623 __vp_[*__i] -= __v[__j]; 1624} 1625 1626template <class _Tp> 1627template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1628inline 1629void 1630gslice_array<_Tp>::operator^=(const _Expr& __v) const 1631{ 1632 typedef const size_t* _Ip; 1633 size_t __j = 0; 1634 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1635 __vp_[*__i] ^= __v[__j]; 1636} 1637 1638template <class _Tp> 1639template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1640inline 1641void 1642gslice_array<_Tp>::operator&=(const _Expr& __v) const 1643{ 1644 typedef const size_t* _Ip; 1645 size_t __j = 0; 1646 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1647 __vp_[*__i] &= __v[__j]; 1648} 1649 1650template <class _Tp> 1651template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1652inline 1653void 1654gslice_array<_Tp>::operator|=(const _Expr& __v) const 1655{ 1656 typedef const size_t* _Ip; 1657 size_t __j = 0; 1658 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1659 __vp_[*__i] |= __v[__j]; 1660} 1661 1662template <class _Tp> 1663template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1664inline 1665void 1666gslice_array<_Tp>::operator<<=(const _Expr& __v) const 1667{ 1668 typedef const size_t* _Ip; 1669 size_t __j = 0; 1670 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1671 __vp_[*__i] <<= __v[__j]; 1672} 1673 1674template <class _Tp> 1675template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1676inline 1677void 1678gslice_array<_Tp>::operator>>=(const _Expr& __v) const 1679{ 1680 typedef const size_t* _Ip; 1681 size_t __j = 0; 1682 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1683 __vp_[*__i] >>= __v[__j]; 1684} 1685 1686template <class _Tp> 1687inline 1688const gslice_array<_Tp>& 1689gslice_array<_Tp>::operator=(const gslice_array& __ga) const 1690{ 1691 typedef const size_t* _Ip; 1692 const value_type* __s = __ga.__vp_; 1693 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; 1694 __i != __e; ++__i, ++__j) 1695 __vp_[*__i] = __s[*__j]; 1696 return *this; 1697} 1698 1699template <class _Tp> 1700inline 1701void 1702gslice_array<_Tp>::operator=(const value_type& __x) const 1703{ 1704 typedef const size_t* _Ip; 1705 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) 1706 __vp_[*__i] = __x; 1707} 1708 1709// mask_array 1710 1711template <class _Tp> 1712class _LIBCPP_TEMPLATE_VIS mask_array 1713{ 1714public: 1715 typedef _Tp value_type; 1716 1717private: 1718 value_type* __vp_; 1719 valarray<size_t> __1d_; 1720 1721public: 1722 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1723 void 1724 _LIBCPP_HIDE_FROM_ABI 1725 operator=(const _Expr& __v) const; 1726 1727 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1728 void 1729 _LIBCPP_HIDE_FROM_ABI 1730 operator*=(const _Expr& __v) const; 1731 1732 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1733 void 1734 _LIBCPP_HIDE_FROM_ABI 1735 operator/=(const _Expr& __v) const; 1736 1737 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1738 void 1739 _LIBCPP_HIDE_FROM_ABI 1740 operator%=(const _Expr& __v) const; 1741 1742 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1743 void 1744 _LIBCPP_HIDE_FROM_ABI 1745 operator+=(const _Expr& __v) const; 1746 1747 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1748 void 1749 _LIBCPP_HIDE_FROM_ABI 1750 operator-=(const _Expr& __v) const; 1751 1752 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1753 void 1754 _LIBCPP_HIDE_FROM_ABI 1755 operator^=(const _Expr& __v) const; 1756 1757 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1758 void 1759 _LIBCPP_HIDE_FROM_ABI 1760 operator&=(const _Expr& __v) const; 1761 1762 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1763 void 1764 _LIBCPP_HIDE_FROM_ABI 1765 operator|=(const _Expr& __v) const; 1766 1767 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1768 void 1769 _LIBCPP_HIDE_FROM_ABI 1770 operator<<=(const _Expr& __v) const; 1771 1772 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1773 void 1774 _LIBCPP_HIDE_FROM_ABI 1775 operator>>=(const _Expr& __v) const; 1776 1777 mask_array(const mask_array&) = default; 1778 1779 _LIBCPP_HIDE_FROM_ABI 1780 const mask_array& operator=(const mask_array& __ma) const; 1781 1782 _LIBCPP_HIDE_FROM_ABI 1783 void operator=(const value_type& __x) const; 1784 1785private: 1786 _LIBCPP_HIDE_FROM_ABI 1787 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v) 1788 : __vp_(const_cast<value_type*>(__v.__begin_)), 1789 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) 1790 { 1791 size_t __j = 0; 1792 for (size_t __i = 0; __i < __vb.size(); ++__i) 1793 if (__vb[__i]) 1794 __1d_[__j++] = __i; 1795 } 1796 1797 template <class> friend class valarray; 1798}; 1799 1800template <class _Tp> 1801template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1802inline 1803 void 1804mask_array<_Tp>::operator=(const _Expr& __v) const 1805{ 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 1814 void 1815mask_array<_Tp>::operator*=(const _Expr& __v) const 1816{ 1817 size_t __n = __1d_.size(); 1818 for (size_t __i = 0; __i < __n; ++__i) 1819 __vp_[__1d_[__i]] *= __v[__i]; 1820} 1821 1822template <class _Tp> 1823template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1824inline 1825 void 1826mask_array<_Tp>::operator/=(const _Expr& __v) const 1827{ 1828 size_t __n = __1d_.size(); 1829 for (size_t __i = 0; __i < __n; ++__i) 1830 __vp_[__1d_[__i]] /= __v[__i]; 1831} 1832 1833template <class _Tp> 1834template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1835inline 1836 void 1837mask_array<_Tp>::operator%=(const _Expr& __v) const 1838{ 1839 size_t __n = __1d_.size(); 1840 for (size_t __i = 0; __i < __n; ++__i) 1841 __vp_[__1d_[__i]] %= __v[__i]; 1842} 1843 1844template <class _Tp> 1845template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1846inline 1847 void 1848mask_array<_Tp>::operator+=(const _Expr& __v) const 1849{ 1850 size_t __n = __1d_.size(); 1851 for (size_t __i = 0; __i < __n; ++__i) 1852 __vp_[__1d_[__i]] += __v[__i]; 1853} 1854 1855template <class _Tp> 1856template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1857inline 1858 void 1859mask_array<_Tp>::operator-=(const _Expr& __v) const 1860{ 1861 size_t __n = __1d_.size(); 1862 for (size_t __i = 0; __i < __n; ++__i) 1863 __vp_[__1d_[__i]] -= __v[__i]; 1864} 1865 1866template <class _Tp> 1867template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1868inline 1869 void 1870mask_array<_Tp>::operator^=(const _Expr& __v) const 1871{ 1872 size_t __n = __1d_.size(); 1873 for (size_t __i = 0; __i < __n; ++__i) 1874 __vp_[__1d_[__i]] ^= __v[__i]; 1875} 1876 1877template <class _Tp> 1878template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1879inline 1880 void 1881mask_array<_Tp>::operator&=(const _Expr& __v) const 1882{ 1883 size_t __n = __1d_.size(); 1884 for (size_t __i = 0; __i < __n; ++__i) 1885 __vp_[__1d_[__i]] &= __v[__i]; 1886} 1887 1888template <class _Tp> 1889template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1890inline 1891 void 1892mask_array<_Tp>::operator|=(const _Expr& __v) const 1893{ 1894 size_t __n = __1d_.size(); 1895 for (size_t __i = 0; __i < __n; ++__i) 1896 __vp_[__1d_[__i]] |= __v[__i]; 1897} 1898 1899template <class _Tp> 1900template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1901inline 1902 void 1903mask_array<_Tp>::operator<<=(const _Expr& __v) const 1904{ 1905 size_t __n = __1d_.size(); 1906 for (size_t __i = 0; __i < __n; ++__i) 1907 __vp_[__1d_[__i]] <<= __v[__i]; 1908} 1909 1910template <class _Tp> 1911template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 1912inline 1913 void 1914mask_array<_Tp>::operator>>=(const _Expr& __v) const 1915{ 1916 size_t __n = __1d_.size(); 1917 for (size_t __i = 0; __i < __n; ++__i) 1918 __vp_[__1d_[__i]] >>= __v[__i]; 1919} 1920 1921template <class _Tp> 1922inline 1923const mask_array<_Tp>& 1924mask_array<_Tp>::operator=(const mask_array& __ma) const 1925{ 1926 size_t __n = __1d_.size(); 1927 for (size_t __i = 0; __i < __n; ++__i) 1928 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]]; 1929 return *this; 1930} 1931 1932template <class _Tp> 1933inline 1934void 1935mask_array<_Tp>::operator=(const value_type& __x) const 1936{ 1937 size_t __n = __1d_.size(); 1938 for (size_t __i = 0; __i < __n; ++__i) 1939 __vp_[__1d_[__i]] = __x; 1940} 1941 1942template <class _ValExpr> 1943class __mask_expr 1944{ 1945 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; 1946public: 1947 typedef typename _RmExpr::value_type value_type; 1948 typedef value_type __result_type; 1949 1950private: 1951 _ValExpr __expr_; 1952 valarray<size_t> __1d_; 1953 1954 _LIBCPP_HIDE_FROM_ABI 1955 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e) 1956 : __expr_(__e), 1957 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) 1958 { 1959 size_t __j = 0; 1960 for (size_t __i = 0; __i < __vb.size(); ++__i) 1961 if (__vb[__i]) 1962 __1d_[__j++] = __i; 1963 } 1964 1965public: 1966 _LIBCPP_HIDE_FROM_ABI 1967 __result_type operator[](size_t __i) const 1968 {return __expr_[__1d_[__i]];} 1969 1970 _LIBCPP_HIDE_FROM_ABI 1971 size_t size() const {return __1d_.size();} 1972 1973 template <class> friend class __val_expr; 1974 template <class> friend class valarray; 1975}; 1976 1977// indirect_array 1978 1979template <class _Tp> 1980class _LIBCPP_TEMPLATE_VIS indirect_array 1981{ 1982public: 1983 typedef _Tp value_type; 1984 1985private: 1986 value_type* __vp_; 1987 valarray<size_t> __1d_; 1988 1989public: 1990 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1991 void 1992 _LIBCPP_HIDE_FROM_ABI 1993 operator=(const _Expr& __v) const; 1994 1995 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 1996 void 1997 _LIBCPP_HIDE_FROM_ABI 1998 operator*=(const _Expr& __v) const; 1999 2000 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2001 void 2002 _LIBCPP_HIDE_FROM_ABI 2003 operator/=(const _Expr& __v) const; 2004 2005 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2006 void 2007 _LIBCPP_HIDE_FROM_ABI 2008 operator%=(const _Expr& __v) const; 2009 2010 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2011 void 2012 _LIBCPP_HIDE_FROM_ABI 2013 operator+=(const _Expr& __v) const; 2014 2015 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2016 void 2017 _LIBCPP_HIDE_FROM_ABI 2018 operator-=(const _Expr& __v) const; 2019 2020 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2021 void 2022 _LIBCPP_HIDE_FROM_ABI 2023 operator^=(const _Expr& __v) const; 2024 2025 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2026 void 2027 _LIBCPP_HIDE_FROM_ABI 2028 operator&=(const _Expr& __v) const; 2029 2030 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2031 void 2032 _LIBCPP_HIDE_FROM_ABI 2033 operator|=(const _Expr& __v) const; 2034 2035 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2036 void 2037 _LIBCPP_HIDE_FROM_ABI 2038 operator<<=(const _Expr& __v) const; 2039 2040 template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 2041 void 2042 _LIBCPP_HIDE_FROM_ABI 2043 operator>>=(const _Expr& __v) const; 2044 2045 indirect_array(const indirect_array&) = default; 2046 2047 _LIBCPP_HIDE_FROM_ABI 2048 const indirect_array& operator=(const indirect_array& __ia) const; 2049 2050 _LIBCPP_HIDE_FROM_ABI 2051 void operator=(const value_type& __x) const; 2052 2053private: 2054 _LIBCPP_HIDE_FROM_ABI 2055 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) 2056 : __vp_(const_cast<value_type*>(__v.__begin_)), 2057 __1d_(__ia) 2058 {} 2059 2060#ifndef _LIBCPP_CXX03_LANG 2061 2062 _LIBCPP_HIDE_FROM_ABI 2063 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v) 2064 : __vp_(const_cast<value_type*>(__v.__begin_)), 2065 __1d_(std::move(__ia)) 2066 {} 2067 2068#endif // _LIBCPP_CXX03_LANG 2069 2070 template <class> friend class valarray; 2071}; 2072 2073template <class _Tp> 2074template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2075inline 2076void 2077indirect_array<_Tp>::operator=(const _Expr& __v) const 2078{ 2079 size_t __n = __1d_.size(); 2080 for (size_t __i = 0; __i < __n; ++__i) 2081 __vp_[__1d_[__i]] = __v[__i]; 2082} 2083 2084template <class _Tp> 2085template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2086inline 2087void 2088indirect_array<_Tp>::operator*=(const _Expr& __v) const 2089{ 2090 size_t __n = __1d_.size(); 2091 for (size_t __i = 0; __i < __n; ++__i) 2092 __vp_[__1d_[__i]] *= __v[__i]; 2093} 2094 2095template <class _Tp> 2096template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2097inline 2098void 2099indirect_array<_Tp>::operator/=(const _Expr& __v) const 2100{ 2101 size_t __n = __1d_.size(); 2102 for (size_t __i = 0; __i < __n; ++__i) 2103 __vp_[__1d_[__i]] /= __v[__i]; 2104} 2105 2106template <class _Tp> 2107template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2108inline 2109void 2110indirect_array<_Tp>::operator%=(const _Expr& __v) const 2111{ 2112 size_t __n = __1d_.size(); 2113 for (size_t __i = 0; __i < __n; ++__i) 2114 __vp_[__1d_[__i]] %= __v[__i]; 2115} 2116 2117template <class _Tp> 2118template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2119inline 2120void 2121indirect_array<_Tp>::operator+=(const _Expr& __v) const 2122{ 2123 size_t __n = __1d_.size(); 2124 for (size_t __i = 0; __i < __n; ++__i) 2125 __vp_[__1d_[__i]] += __v[__i]; 2126} 2127 2128template <class _Tp> 2129template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2130inline 2131void 2132indirect_array<_Tp>::operator-=(const _Expr& __v) const 2133{ 2134 size_t __n = __1d_.size(); 2135 for (size_t __i = 0; __i < __n; ++__i) 2136 __vp_[__1d_[__i]] -= __v[__i]; 2137} 2138 2139template <class _Tp> 2140template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2141inline 2142void 2143indirect_array<_Tp>::operator^=(const _Expr& __v) const 2144{ 2145 size_t __n = __1d_.size(); 2146 for (size_t __i = 0; __i < __n; ++__i) 2147 __vp_[__1d_[__i]] ^= __v[__i]; 2148} 2149 2150template <class _Tp> 2151template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2152inline 2153void 2154indirect_array<_Tp>::operator&=(const _Expr& __v) const 2155{ 2156 size_t __n = __1d_.size(); 2157 for (size_t __i = 0; __i < __n; ++__i) 2158 __vp_[__1d_[__i]] &= __v[__i]; 2159} 2160 2161template <class _Tp> 2162template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2163inline 2164void 2165indirect_array<_Tp>::operator|=(const _Expr& __v) const 2166{ 2167 size_t __n = __1d_.size(); 2168 for (size_t __i = 0; __i < __n; ++__i) 2169 __vp_[__1d_[__i]] |= __v[__i]; 2170} 2171 2172template <class _Tp> 2173template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2174inline 2175void 2176indirect_array<_Tp>::operator<<=(const _Expr& __v) const 2177{ 2178 size_t __n = __1d_.size(); 2179 for (size_t __i = 0; __i < __n; ++__i) 2180 __vp_[__1d_[__i]] <<= __v[__i]; 2181} 2182 2183template <class _Tp> 2184template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 2185inline 2186void 2187indirect_array<_Tp>::operator>>=(const _Expr& __v) const 2188{ 2189 size_t __n = __1d_.size(); 2190 for (size_t __i = 0; __i < __n; ++__i) 2191 __vp_[__1d_[__i]] >>= __v[__i]; 2192} 2193 2194template <class _Tp> 2195inline 2196const indirect_array<_Tp>& 2197indirect_array<_Tp>::operator=(const indirect_array& __ia) const 2198{ 2199 typedef const size_t* _Ip; 2200 const value_type* __s = __ia.__vp_; 2201 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; 2202 __i != __e; ++__i, ++__j) 2203 __vp_[*__i] = __s[*__j]; 2204 return *this; 2205} 2206 2207template <class _Tp> 2208inline 2209void 2210indirect_array<_Tp>::operator=(const value_type& __x) const 2211{ 2212 typedef const size_t* _Ip; 2213 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) 2214 __vp_[*__i] = __x; 2215} 2216 2217template <class _ValExpr> 2218class __indirect_expr 2219{ 2220 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; 2221public: 2222 typedef typename _RmExpr::value_type value_type; 2223 typedef value_type __result_type; 2224 2225private: 2226 _ValExpr __expr_; 2227 valarray<size_t> __1d_; 2228 2229 _LIBCPP_HIDE_FROM_ABI 2230 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) 2231 : __expr_(__e), 2232 __1d_(__ia) 2233 {} 2234 2235#ifndef _LIBCPP_CXX03_LANG 2236 2237 _LIBCPP_HIDE_FROM_ABI 2238 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e) 2239 : __expr_(__e), 2240 __1d_(std::move(__ia)) 2241 {} 2242 2243#endif // _LIBCPP_CXX03_LANG 2244 2245public: 2246 _LIBCPP_HIDE_FROM_ABI 2247 __result_type operator[](size_t __i) const 2248 {return __expr_[__1d_[__i]];} 2249 2250 _LIBCPP_HIDE_FROM_ABI 2251 size_t size() const {return __1d_.size();} 2252 2253 template <class> friend class __val_expr; 2254 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; 2255}; 2256 2257template<class _ValExpr> 2258class __val_expr 2259{ 2260 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; 2261 2262 _ValExpr __expr_; 2263public: 2264 typedef typename _RmExpr::value_type value_type; 2265 typedef typename _RmExpr::__result_type __result_type; 2266 2267 _LIBCPP_HIDE_FROM_ABI 2268 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {} 2269 2270 _LIBCPP_HIDE_FROM_ABI 2271 __result_type operator[](size_t __i) const 2272 {return __expr_[__i];} 2273 2274 _LIBCPP_HIDE_FROM_ABI 2275 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const 2276 { 2277 typedef __slice_expr<_ValExpr> _NewExpr; 2278 return __val_expr< _NewExpr >(_NewExpr(__s, __expr_)); 2279 } 2280 2281 _LIBCPP_HIDE_FROM_ABI 2282 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const 2283 { 2284 typedef __indirect_expr<_ValExpr> _NewExpr; 2285 return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_)); 2286 } 2287 2288 _LIBCPP_HIDE_FROM_ABI 2289 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const 2290 { 2291 typedef __mask_expr<_ValExpr> _NewExpr; 2292 return __val_expr< _NewExpr >( _NewExpr(__vb, __expr_)); 2293 } 2294 2295 _LIBCPP_HIDE_FROM_ABI 2296 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const 2297 { 2298 typedef __indirect_expr<_ValExpr> _NewExpr; 2299 return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_)); 2300 } 2301 2302 _LIBCPP_HIDE_FROM_ABI 2303 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > 2304 operator+() const 2305 { 2306 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr; 2307 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_)); 2308 } 2309 2310 _LIBCPP_HIDE_FROM_ABI 2311 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > 2312 operator-() const 2313 { 2314 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr; 2315 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_)); 2316 } 2317 2318 _LIBCPP_HIDE_FROM_ABI 2319 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > 2320 operator~() const 2321 { 2322 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr; 2323 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_)); 2324 } 2325 2326 _LIBCPP_HIDE_FROM_ABI 2327 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > 2328 operator!() const 2329 { 2330 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr; 2331 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_)); 2332 } 2333 2334 operator valarray<__result_type>() const; 2335 2336 _LIBCPP_HIDE_FROM_ABI 2337 size_t size() const {return __expr_.size();} 2338 2339 _LIBCPP_HIDE_FROM_ABI 2340 __result_type sum() const 2341 { 2342 size_t __n = __expr_.size(); 2343 __result_type __r = __n ? __expr_[0] : __result_type(); 2344 for (size_t __i = 1; __i < __n; ++__i) 2345 __r += __expr_[__i]; 2346 return __r; 2347 } 2348 2349 _LIBCPP_HIDE_FROM_ABI 2350 __result_type min() const 2351 { 2352 size_t __n = size(); 2353 __result_type __r = __n ? (*this)[0] : __result_type(); 2354 for (size_t __i = 1; __i < __n; ++__i) 2355 { 2356 __result_type __x = __expr_[__i]; 2357 if (__x < __r) 2358 __r = __x; 2359 } 2360 return __r; 2361 } 2362 2363 _LIBCPP_HIDE_FROM_ABI 2364 __result_type max() const 2365 { 2366 size_t __n = size(); 2367 __result_type __r = __n ? (*this)[0] : __result_type(); 2368 for (size_t __i = 1; __i < __n; ++__i) 2369 { 2370 __result_type __x = __expr_[__i]; 2371 if (__r < __x) 2372 __r = __x; 2373 } 2374 return __r; 2375 } 2376 2377 _LIBCPP_HIDE_FROM_ABI 2378 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const 2379 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));} 2380 2381 _LIBCPP_HIDE_FROM_ABI 2382 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const 2383 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));} 2384 2385 _LIBCPP_HIDE_FROM_ABI 2386 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> > 2387 apply(value_type __f(value_type)) const 2388 { 2389 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op; 2390 typedef _UnaryOp<_Op, _ValExpr> _NewExpr; 2391 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); 2392 } 2393 2394 _LIBCPP_HIDE_FROM_ABI 2395 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> > 2396 apply(value_type __f(const value_type&)) const 2397 { 2398 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op; 2399 typedef _UnaryOp<_Op, _ValExpr> _NewExpr; 2400 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); 2401 } 2402}; 2403 2404template<class _ValExpr> 2405__val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const 2406{ 2407 valarray<__result_type> __r; 2408 size_t __n = __expr_.size(); 2409 if (__n) 2410 { 2411 __r.__begin_ = 2412 __r.__end_ = allocator<__result_type>().allocate(__n); 2413 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) 2414 ::new ((void*)__r.__end_) __result_type(__expr_[__i]); 2415 } 2416 return __r; 2417} 2418 2419// valarray 2420 2421template <class _Tp> 2422inline 2423valarray<_Tp>::valarray(size_t __n) 2424 : __begin_(nullptr), 2425 __end_(nullptr) 2426{ 2427 if (__n) 2428 { 2429 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2430#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2431 try 2432 { 2433#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2434 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) 2435 ::new ((void*)__end_) value_type(); 2436#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2437 } 2438 catch (...) 2439 { 2440 __clear(__n); 2441 throw; 2442 } 2443#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2444 } 2445} 2446 2447template <class _Tp> 2448inline 2449valarray<_Tp>::valarray(const value_type& __x, size_t __n) 2450 : __begin_(nullptr), 2451 __end_(nullptr) 2452{ 2453 resize(__n, __x); 2454} 2455 2456template <class _Tp> 2457valarray<_Tp>::valarray(const value_type* __p, size_t __n) 2458 : __begin_(nullptr), 2459 __end_(nullptr) 2460{ 2461 if (__n) 2462 { 2463 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2464#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2465 try 2466 { 2467#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2468 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) 2469 ::new ((void*)__end_) value_type(*__p); 2470#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2471 } 2472 catch (...) 2473 { 2474 __clear(__n); 2475 throw; 2476 } 2477#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2478 } 2479} 2480 2481template <class _Tp> 2482valarray<_Tp>::valarray(const valarray& __v) 2483 : __begin_(nullptr), 2484 __end_(nullptr) 2485{ 2486 if (__v.size()) 2487 { 2488 __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); 2489#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2490 try 2491 { 2492#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2493 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) 2494 ::new ((void*)__end_) value_type(*__p); 2495#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2496 } 2497 catch (...) 2498 { 2499 __clear(__v.size()); 2500 throw; 2501 } 2502#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2503 } 2504} 2505 2506#ifndef _LIBCPP_CXX03_LANG 2507 2508template <class _Tp> 2509inline 2510valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT 2511 : __begin_(__v.__begin_), 2512 __end_(__v.__end_) 2513{ 2514 __v.__begin_ = __v.__end_ = nullptr; 2515} 2516 2517template <class _Tp> 2518valarray<_Tp>::valarray(initializer_list<value_type> __il) 2519 : __begin_(nullptr), 2520 __end_(nullptr) 2521{ 2522 const size_t __n = __il.size(); 2523 if (__n) 2524 { 2525 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2526#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2527 try 2528 { 2529#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2530 size_t __n_left = __n; 2531 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) 2532 ::new ((void*)__end_) value_type(*__p); 2533#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2534 } 2535 catch (...) 2536 { 2537 __clear(__n); 2538 throw; 2539 } 2540#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2541 } 2542} 2543 2544#endif // _LIBCPP_CXX03_LANG 2545 2546template <class _Tp> 2547valarray<_Tp>::valarray(const slice_array<value_type>& __sa) 2548 : __begin_(nullptr), 2549 __end_(nullptr) 2550{ 2551 const size_t __n = __sa.__size_; 2552 if (__n) 2553 { 2554 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2555#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2556 try 2557 { 2558#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2559 size_t __n_left = __n; 2560 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) 2561 ::new ((void*)__end_) value_type(*__p); 2562#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2563 } 2564 catch (...) 2565 { 2566 __clear(__n); 2567 throw; 2568 } 2569#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2570 } 2571} 2572 2573template <class _Tp> 2574valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) 2575 : __begin_(nullptr), 2576 __end_(nullptr) 2577{ 2578 const size_t __n = __ga.__1d_.size(); 2579 if (__n) 2580 { 2581 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2582#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2583 try 2584 { 2585#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2586 typedef const size_t* _Ip; 2587 const value_type* __s = __ga.__vp_; 2588 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; 2589 __i != __e; ++__i, ++__end_) 2590 ::new ((void*)__end_) value_type(__s[*__i]); 2591#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2592 } 2593 catch (...) 2594 { 2595 __clear(__n); 2596 throw; 2597 } 2598#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2599 } 2600} 2601 2602template <class _Tp> 2603valarray<_Tp>::valarray(const mask_array<value_type>& __ma) 2604 : __begin_(nullptr), 2605 __end_(nullptr) 2606{ 2607 const size_t __n = __ma.__1d_.size(); 2608 if (__n) 2609 { 2610 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2611#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2612 try 2613 { 2614#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2615 typedef const size_t* _Ip; 2616 const value_type* __s = __ma.__vp_; 2617 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; 2618 __i != __e; ++__i, ++__end_) 2619 ::new ((void*)__end_) value_type(__s[*__i]); 2620#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2621 } 2622 catch (...) 2623 { 2624 __clear(__n); 2625 throw; 2626 } 2627#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2628 } 2629} 2630 2631template <class _Tp> 2632valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) 2633 : __begin_(nullptr), 2634 __end_(nullptr) 2635{ 2636 const size_t __n = __ia.__1d_.size(); 2637 if (__n) 2638 { 2639 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2640#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2641 try 2642 { 2643#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2644 typedef const size_t* _Ip; 2645 const value_type* __s = __ia.__vp_; 2646 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; 2647 __i != __e; ++__i, ++__end_) 2648 ::new ((void*)__end_) value_type(__s[*__i]); 2649#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 2650 } 2651 catch (...) 2652 { 2653 __clear(__n); 2654 throw; 2655 } 2656#endif // _LIBCPP_HAS_NO_EXCEPTIONS 2657 } 2658} 2659 2660template <class _Tp> 2661inline 2662valarray<_Tp>::~valarray() 2663{ 2664 __clear(size()); 2665} 2666 2667template <class _Tp> 2668valarray<_Tp>& 2669valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) 2670{ 2671 size_t __n = __l - __f; 2672 if (size() != __n) 2673 { 2674 __clear(size()); 2675 __begin_ = allocator<value_type>().allocate(__n); 2676 __end_ = __begin_ + __n; 2677 std::uninitialized_copy(__f, __l, __begin_); 2678 } else { 2679 std::copy(__f, __l, __begin_); 2680 } 2681 return *this; 2682} 2683 2684template <class _Tp> 2685valarray<_Tp>& 2686valarray<_Tp>::operator=(const valarray& __v) 2687{ 2688 if (this != std::addressof(__v)) 2689 return __assign_range(__v.__begin_, __v.__end_); 2690 return *this; 2691} 2692 2693#ifndef _LIBCPP_CXX03_LANG 2694 2695template <class _Tp> 2696inline 2697valarray<_Tp>& 2698valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT 2699{ 2700 __clear(size()); 2701 __begin_ = __v.__begin_; 2702 __end_ = __v.__end_; 2703 __v.__begin_ = nullptr; 2704 __v.__end_ = nullptr; 2705 return *this; 2706} 2707 2708template <class _Tp> 2709inline 2710valarray<_Tp>& 2711valarray<_Tp>::operator=(initializer_list<value_type> __il) 2712{ 2713 return __assign_range(__il.begin(), __il.end()); 2714} 2715 2716#endif // _LIBCPP_CXX03_LANG 2717 2718template <class _Tp> 2719inline 2720valarray<_Tp>& 2721valarray<_Tp>::operator=(const value_type& __x) 2722{ 2723 std::fill(__begin_, __end_, __x); 2724 return *this; 2725} 2726 2727template <class _Tp> 2728inline 2729valarray<_Tp>& 2730valarray<_Tp>::operator=(const slice_array<value_type>& __sa) 2731{ 2732 value_type* __t = __begin_; 2733 const value_type* __s = __sa.__vp_; 2734 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t) 2735 *__t = *__s; 2736 return *this; 2737} 2738 2739template <class _Tp> 2740inline 2741valarray<_Tp>& 2742valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) 2743{ 2744 typedef const size_t* _Ip; 2745 value_type* __t = __begin_; 2746 const value_type* __s = __ga.__vp_; 2747 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; 2748 __i != __e; ++__i, ++__t) 2749 *__t = __s[*__i]; 2750 return *this; 2751} 2752 2753template <class _Tp> 2754inline 2755valarray<_Tp>& 2756valarray<_Tp>::operator=(const mask_array<value_type>& __ma) 2757{ 2758 typedef const size_t* _Ip; 2759 value_type* __t = __begin_; 2760 const value_type* __s = __ma.__vp_; 2761 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; 2762 __i != __e; ++__i, ++__t) 2763 *__t = __s[*__i]; 2764 return *this; 2765} 2766 2767template <class _Tp> 2768inline 2769valarray<_Tp>& 2770valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) 2771{ 2772 typedef const size_t* _Ip; 2773 value_type* __t = __begin_; 2774 const value_type* __s = __ia.__vp_; 2775 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; 2776 __i != __e; ++__i, ++__t) 2777 *__t = __s[*__i]; 2778 return *this; 2779} 2780 2781template <class _Tp> 2782template <class _ValExpr> 2783inline 2784valarray<_Tp>& 2785valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) 2786{ 2787 size_t __n = __v.size(); 2788 if (size() != __n) 2789 resize(__n); 2790 value_type* __t = __begin_; 2791 for (size_t __i = 0; __i != __n; ++__t, ++__i) 2792 *__t = __result_type(__v[__i]); 2793 return *this; 2794} 2795 2796template <class _Tp> 2797inline 2798__val_expr<__slice_expr<const valarray<_Tp>&> > 2799valarray<_Tp>::operator[](slice __s) const 2800{ 2801 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this)); 2802} 2803 2804template <class _Tp> 2805inline 2806slice_array<_Tp> 2807valarray<_Tp>::operator[](slice __s) 2808{ 2809 return slice_array<value_type>(__s, *this); 2810} 2811 2812template <class _Tp> 2813inline 2814__val_expr<__indirect_expr<const valarray<_Tp>&> > 2815valarray<_Tp>::operator[](const gslice& __gs) const 2816{ 2817 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this)); 2818} 2819 2820template <class _Tp> 2821inline 2822gslice_array<_Tp> 2823valarray<_Tp>::operator[](const gslice& __gs) 2824{ 2825 return gslice_array<value_type>(__gs, *this); 2826} 2827 2828#ifndef _LIBCPP_CXX03_LANG 2829 2830template <class _Tp> 2831inline 2832__val_expr<__indirect_expr<const valarray<_Tp>&> > 2833valarray<_Tp>::operator[](gslice&& __gs) const 2834{ 2835 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this)); 2836} 2837 2838template <class _Tp> 2839inline 2840gslice_array<_Tp> 2841valarray<_Tp>::operator[](gslice&& __gs) 2842{ 2843 return gslice_array<value_type>(std::move(__gs), *this); 2844} 2845 2846#endif // _LIBCPP_CXX03_LANG 2847 2848template <class _Tp> 2849inline 2850__val_expr<__mask_expr<const valarray<_Tp>&> > 2851valarray<_Tp>::operator[](const valarray<bool>& __vb) const 2852{ 2853 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this)); 2854} 2855 2856template <class _Tp> 2857inline 2858mask_array<_Tp> 2859valarray<_Tp>::operator[](const valarray<bool>& __vb) 2860{ 2861 return mask_array<value_type>(__vb, *this); 2862} 2863 2864#ifndef _LIBCPP_CXX03_LANG 2865 2866template <class _Tp> 2867inline 2868__val_expr<__mask_expr<const valarray<_Tp>&> > 2869valarray<_Tp>::operator[](valarray<bool>&& __vb) const 2870{ 2871 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this)); 2872} 2873 2874template <class _Tp> 2875inline 2876mask_array<_Tp> 2877valarray<_Tp>::operator[](valarray<bool>&& __vb) 2878{ 2879 return mask_array<value_type>(std::move(__vb), *this); 2880} 2881 2882#endif // _LIBCPP_CXX03_LANG 2883 2884template <class _Tp> 2885inline 2886__val_expr<__indirect_expr<const valarray<_Tp>&> > 2887valarray<_Tp>::operator[](const valarray<size_t>& __vs) const 2888{ 2889 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this)); 2890} 2891 2892template <class _Tp> 2893inline 2894indirect_array<_Tp> 2895valarray<_Tp>::operator[](const valarray<size_t>& __vs) 2896{ 2897 return indirect_array<value_type>(__vs, *this); 2898} 2899 2900#ifndef _LIBCPP_CXX03_LANG 2901 2902template <class _Tp> 2903inline 2904__val_expr<__indirect_expr<const valarray<_Tp>&> > 2905valarray<_Tp>::operator[](valarray<size_t>&& __vs) const 2906{ 2907 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this)); 2908} 2909 2910template <class _Tp> 2911inline 2912indirect_array<_Tp> 2913valarray<_Tp>::operator[](valarray<size_t>&& __vs) 2914{ 2915 return indirect_array<value_type>(std::move(__vs), *this); 2916} 2917 2918#endif // _LIBCPP_CXX03_LANG 2919 2920template <class _Tp> 2921inline 2922__val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > 2923valarray<_Tp>::operator+() const 2924{ 2925 using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>; 2926 return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this)); 2927} 2928 2929template <class _Tp> 2930inline 2931__val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > 2932valarray<_Tp>::operator-() const 2933{ 2934 using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>; 2935 return __val_expr<_Op>(_Op(negate<_Tp>(), *this)); 2936} 2937 2938template <class _Tp> 2939inline 2940__val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > 2941valarray<_Tp>::operator~() const 2942{ 2943 using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>; 2944 return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this)); 2945} 2946 2947template <class _Tp> 2948inline 2949__val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > 2950valarray<_Tp>::operator!() const 2951{ 2952 using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>; 2953 return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this)); 2954} 2955 2956template <class _Tp> 2957inline 2958valarray<_Tp>& 2959valarray<_Tp>::operator*=(const value_type& __x) 2960{ 2961 for (value_type* __p = __begin_; __p != __end_; ++__p) 2962 *__p *= __x; 2963 return *this; 2964} 2965 2966template <class _Tp> 2967inline 2968valarray<_Tp>& 2969valarray<_Tp>::operator/=(const value_type& __x) 2970{ 2971 for (value_type* __p = __begin_; __p != __end_; ++__p) 2972 *__p /= __x; 2973 return *this; 2974} 2975 2976template <class _Tp> 2977inline 2978valarray<_Tp>& 2979valarray<_Tp>::operator%=(const value_type& __x) 2980{ 2981 for (value_type* __p = __begin_; __p != __end_; ++__p) 2982 *__p %= __x; 2983 return *this; 2984} 2985 2986template <class _Tp> 2987inline 2988valarray<_Tp>& 2989valarray<_Tp>::operator+=(const value_type& __x) 2990{ 2991 for (value_type* __p = __begin_; __p != __end_; ++__p) 2992 *__p += __x; 2993 return *this; 2994} 2995 2996template <class _Tp> 2997inline 2998valarray<_Tp>& 2999valarray<_Tp>::operator-=(const value_type& __x) 3000{ 3001 for (value_type* __p = __begin_; __p != __end_; ++__p) 3002 *__p -= __x; 3003 return *this; 3004} 3005 3006template <class _Tp> 3007inline 3008valarray<_Tp>& 3009valarray<_Tp>::operator^=(const value_type& __x) 3010{ 3011 for (value_type* __p = __begin_; __p != __end_; ++__p) 3012 *__p ^= __x; 3013 return *this; 3014} 3015 3016template <class _Tp> 3017inline 3018valarray<_Tp>& 3019valarray<_Tp>::operator&=(const value_type& __x) 3020{ 3021 for (value_type* __p = __begin_; __p != __end_; ++__p) 3022 *__p &= __x; 3023 return *this; 3024} 3025 3026template <class _Tp> 3027inline 3028valarray<_Tp>& 3029valarray<_Tp>::operator|=(const value_type& __x) 3030{ 3031 for (value_type* __p = __begin_; __p != __end_; ++__p) 3032 *__p |= __x; 3033 return *this; 3034} 3035 3036template <class _Tp> 3037inline 3038valarray<_Tp>& 3039valarray<_Tp>::operator<<=(const value_type& __x) 3040{ 3041 for (value_type* __p = __begin_; __p != __end_; ++__p) 3042 *__p <<= __x; 3043 return *this; 3044} 3045 3046template <class _Tp> 3047inline 3048valarray<_Tp>& 3049valarray<_Tp>::operator>>=(const value_type& __x) 3050{ 3051 for (value_type* __p = __begin_; __p != __end_; ++__p) 3052 *__p >>= __x; 3053 return *this; 3054} 3055 3056template <class _Tp> 3057template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3058inline 3059 valarray<_Tp>& 3060valarray<_Tp>::operator*=(const _Expr& __v) 3061{ 3062 size_t __i = 0; 3063 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3064 *__t *= __v[__i]; 3065 return *this; 3066} 3067 3068template <class _Tp> 3069template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3070inline 3071 valarray<_Tp>& 3072valarray<_Tp>::operator/=(const _Expr& __v) 3073{ 3074 size_t __i = 0; 3075 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3076 *__t /= __v[__i]; 3077 return *this; 3078} 3079 3080template <class _Tp> 3081template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3082inline 3083 valarray<_Tp>& 3084valarray<_Tp>::operator%=(const _Expr& __v) 3085{ 3086 size_t __i = 0; 3087 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3088 *__t %= __v[__i]; 3089 return *this; 3090} 3091 3092template <class _Tp> 3093template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3094inline 3095 valarray<_Tp>& 3096valarray<_Tp>::operator+=(const _Expr& __v) 3097{ 3098 size_t __i = 0; 3099 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3100 *__t += __v[__i]; 3101 return *this; 3102} 3103 3104template <class _Tp> 3105template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3106inline 3107 valarray<_Tp>& 3108valarray<_Tp>::operator-=(const _Expr& __v) 3109{ 3110 size_t __i = 0; 3111 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3112 *__t -= __v[__i]; 3113 return *this; 3114} 3115 3116template <class _Tp> 3117template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3118inline 3119 valarray<_Tp>& 3120valarray<_Tp>::operator^=(const _Expr& __v) 3121{ 3122 size_t __i = 0; 3123 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3124 *__t ^= __v[__i]; 3125 return *this; 3126} 3127 3128template <class _Tp> 3129template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3130inline 3131 valarray<_Tp>& 3132valarray<_Tp>::operator|=(const _Expr& __v) 3133{ 3134 size_t __i = 0; 3135 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3136 *__t |= __v[__i]; 3137 return *this; 3138} 3139 3140template <class _Tp> 3141template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3142inline 3143 valarray<_Tp>& 3144valarray<_Tp>::operator&=(const _Expr& __v) 3145{ 3146 size_t __i = 0; 3147 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3148 *__t &= __v[__i]; 3149 return *this; 3150} 3151 3152template <class _Tp> 3153template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3154inline 3155 valarray<_Tp>& 3156valarray<_Tp>::operator<<=(const _Expr& __v) 3157{ 3158 size_t __i = 0; 3159 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3160 *__t <<= __v[__i]; 3161 return *this; 3162} 3163 3164template <class _Tp> 3165template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > 3166inline 3167 valarray<_Tp>& 3168valarray<_Tp>::operator>>=(const _Expr& __v) 3169{ 3170 size_t __i = 0; 3171 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3172 *__t >>= __v[__i]; 3173 return *this; 3174} 3175 3176template <class _Tp> 3177inline 3178void 3179valarray<_Tp>::swap(valarray& __v) _NOEXCEPT 3180{ 3181 std::swap(__begin_, __v.__begin_); 3182 std::swap(__end_, __v.__end_); 3183} 3184 3185template <class _Tp> 3186inline 3187_Tp 3188valarray<_Tp>::sum() const 3189{ 3190 if (__begin_ == __end_) 3191 return value_type(); 3192 const value_type* __p = __begin_; 3193 _Tp __r = *__p; 3194 for (++__p; __p != __end_; ++__p) 3195 __r += *__p; 3196 return __r; 3197} 3198 3199template <class _Tp> 3200inline 3201_Tp 3202valarray<_Tp>::min() const 3203{ 3204 if (__begin_ == __end_) 3205 return value_type(); 3206 return *std::min_element(__begin_, __end_); 3207} 3208 3209template <class _Tp> 3210inline 3211_Tp 3212valarray<_Tp>::max() const 3213{ 3214 if (__begin_ == __end_) 3215 return value_type(); 3216 return *std::max_element(__begin_, __end_); 3217} 3218 3219template <class _Tp> 3220valarray<_Tp> 3221valarray<_Tp>::shift(int __i) const 3222{ 3223 valarray<value_type> __r; 3224 size_t __n = size(); 3225 if (__n) 3226 { 3227 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3228 const value_type* __sb; 3229 value_type* __tb; 3230 value_type* __te; 3231 if (__i >= 0) 3232 { 3233 __i = std::min(__i, static_cast<int>(__n)); 3234 __sb = __begin_ + __i; 3235 __tb = __r.__begin_; 3236 __te = __r.__begin_ + (__n - __i); 3237 } 3238 else 3239 { 3240 __i = std::min(-__i, static_cast<int>(__n)); 3241 __sb = __begin_; 3242 __tb = __r.__begin_ + __i; 3243 __te = __r.__begin_ + __n; 3244 } 3245 for (; __r.__end_ != __tb; ++__r.__end_) 3246 ::new ((void*)__r.__end_) value_type(); 3247 for (; __r.__end_ != __te; ++__r.__end_, ++__sb) 3248 ::new ((void*)__r.__end_) value_type(*__sb); 3249 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_) 3250 ::new ((void*)__r.__end_) value_type(); 3251 } 3252 return __r; 3253} 3254 3255template <class _Tp> 3256valarray<_Tp> 3257valarray<_Tp>::cshift(int __i) const 3258{ 3259 valarray<value_type> __r; 3260 size_t __n = size(); 3261 if (__n) 3262 { 3263 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3264 __i %= static_cast<int>(__n); 3265 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i; 3266 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s) 3267 ::new ((void*)__r.__end_) value_type(*__s); 3268 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s) 3269 ::new ((void*)__r.__end_) value_type(*__s); 3270 } 3271 return __r; 3272} 3273 3274template <class _Tp> 3275valarray<_Tp> 3276valarray<_Tp>::apply(value_type __f(value_type)) const 3277{ 3278 valarray<value_type> __r; 3279 size_t __n = size(); 3280 if (__n) 3281 { 3282 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3283 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) 3284 ::new ((void*)__r.__end_) value_type(__f(*__p)); 3285 } 3286 return __r; 3287} 3288 3289template <class _Tp> 3290valarray<_Tp> 3291valarray<_Tp>::apply(value_type __f(const value_type&)) const 3292{ 3293 valarray<value_type> __r; 3294 size_t __n = size(); 3295 if (__n) 3296 { 3297 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3298 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) 3299 ::new ((void*)__r.__end_) value_type(__f(*__p)); 3300 } 3301 return __r; 3302} 3303 3304template <class _Tp> 3305inline 3306void valarray<_Tp>::__clear(size_t __capacity) 3307{ 3308 if (__begin_ != nullptr) 3309 { 3310 while (__end_ != __begin_) 3311 (--__end_)->~value_type(); 3312 allocator<value_type>().deallocate(__begin_, __capacity); 3313 __begin_ = __end_ = nullptr; 3314 } 3315} 3316 3317template <class _Tp> 3318void 3319valarray<_Tp>::resize(size_t __n, value_type __x) 3320{ 3321 __clear(size()); 3322 if (__n) 3323 { 3324 __begin_ = __end_ = allocator<value_type>().allocate(__n); 3325#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 3326 try 3327 { 3328#endif // _LIBCPP_HAS_NO_EXCEPTIONS 3329 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) 3330 ::new ((void*)__end_) value_type(__x); 3331#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 3332 } 3333 catch (...) 3334 { 3335 __clear(__n); 3336 throw; 3337 } 3338#endif // _LIBCPP_HAS_NO_EXCEPTIONS 3339 } 3340} 3341 3342template<class _Tp> 3343inline _LIBCPP_HIDE_FROM_ABI 3344void 3345swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT 3346{ 3347 __x.swap(__y); 3348} 3349 3350template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3351inline _LIBCPP_HIDE_FROM_ABI 3352__val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> > 3353operator*(const _Expr1& __x, const _Expr2& __y) 3354{ 3355 typedef typename _Expr1::value_type value_type; 3356 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op; 3357 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y)); 3358} 3359 3360template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3361inline _LIBCPP_HIDE_FROM_ABI 3362__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, 3363 _Expr, __scalar_expr<typename _Expr::value_type> > > 3364operator*(const _Expr& __x, const typename _Expr::value_type& __y) 3365{ 3366 typedef typename _Expr::value_type value_type; 3367 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3368 return __val_expr<_Op>(_Op(multiplies<value_type>(), 3369 __x, __scalar_expr<value_type>(__y, __x.size()))); 3370} 3371 3372template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3373inline _LIBCPP_HIDE_FROM_ABI 3374__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, 3375 __scalar_expr<typename _Expr::value_type>, _Expr> > 3376operator*(const typename _Expr::value_type& __x, const _Expr& __y) 3377{ 3378 typedef typename _Expr::value_type value_type; 3379 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3380 return __val_expr<_Op>(_Op(multiplies<value_type>(), 3381 __scalar_expr<value_type>(__x, __y.size()), __y)); 3382} 3383 3384template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3385inline _LIBCPP_HIDE_FROM_ABI 3386__val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> > 3387operator/(const _Expr1& __x, const _Expr2& __y) 3388{ 3389 typedef typename _Expr1::value_type value_type; 3390 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op; 3391 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y)); 3392} 3393 3394template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3395inline _LIBCPP_HIDE_FROM_ABI 3396__val_expr<_BinaryOp<divides<typename _Expr::value_type>, 3397 _Expr, __scalar_expr<typename _Expr::value_type> > > 3398operator/(const _Expr& __x, const typename _Expr::value_type& __y) 3399{ 3400 typedef typename _Expr::value_type value_type; 3401 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3402 return __val_expr<_Op>(_Op(divides<value_type>(), 3403 __x, __scalar_expr<value_type>(__y, __x.size()))); 3404} 3405 3406template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3407inline _LIBCPP_HIDE_FROM_ABI 3408__val_expr<_BinaryOp<divides<typename _Expr::value_type>, 3409 __scalar_expr<typename _Expr::value_type>, _Expr> > 3410operator/(const typename _Expr::value_type& __x, const _Expr& __y) 3411{ 3412 typedef typename _Expr::value_type value_type; 3413 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3414 return __val_expr<_Op>(_Op(divides<value_type>(), 3415 __scalar_expr<value_type>(__x, __y.size()), __y)); 3416} 3417 3418template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3419inline _LIBCPP_HIDE_FROM_ABI 3420__val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> > 3421operator%(const _Expr1& __x, const _Expr2& __y) 3422{ 3423 typedef typename _Expr1::value_type value_type; 3424 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op; 3425 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y)); 3426} 3427 3428template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3429inline _LIBCPP_HIDE_FROM_ABI 3430__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, 3431 _Expr, __scalar_expr<typename _Expr::value_type> > > 3432operator%(const _Expr& __x, const typename _Expr::value_type& __y) 3433{ 3434 typedef typename _Expr::value_type value_type; 3435 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3436 return __val_expr<_Op>(_Op(modulus<value_type>(), 3437 __x, __scalar_expr<value_type>(__y, __x.size()))); 3438} 3439 3440template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3441inline _LIBCPP_HIDE_FROM_ABI 3442__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, 3443 __scalar_expr<typename _Expr::value_type>, _Expr> > 3444operator%(const typename _Expr::value_type& __x, const _Expr& __y) 3445{ 3446 typedef typename _Expr::value_type value_type; 3447 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3448 return __val_expr<_Op>(_Op(modulus<value_type>(), 3449 __scalar_expr<value_type>(__x, __y.size()), __y)); 3450} 3451 3452template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3453inline _LIBCPP_HIDE_FROM_ABI 3454__val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> > 3455operator+(const _Expr1& __x, const _Expr2& __y) 3456{ 3457 typedef typename _Expr1::value_type value_type; 3458 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op; 3459 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y)); 3460} 3461 3462template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3463inline _LIBCPP_HIDE_FROM_ABI 3464__val_expr<_BinaryOp<plus<typename _Expr::value_type>, 3465 _Expr, __scalar_expr<typename _Expr::value_type> > > 3466operator+(const _Expr& __x, const typename _Expr::value_type& __y) 3467{ 3468 typedef typename _Expr::value_type value_type; 3469 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3470 return __val_expr<_Op>(_Op(plus<value_type>(), 3471 __x, __scalar_expr<value_type>(__y, __x.size()))); 3472} 3473 3474template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3475inline _LIBCPP_HIDE_FROM_ABI 3476__val_expr<_BinaryOp<plus<typename _Expr::value_type>, 3477 __scalar_expr<typename _Expr::value_type>, _Expr> > 3478operator+(const typename _Expr::value_type& __x, const _Expr& __y) 3479{ 3480 typedef typename _Expr::value_type value_type; 3481 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3482 return __val_expr<_Op>(_Op(plus<value_type>(), 3483 __scalar_expr<value_type>(__x, __y.size()), __y)); 3484} 3485 3486template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3487inline _LIBCPP_HIDE_FROM_ABI 3488__val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> > 3489operator-(const _Expr1& __x, const _Expr2& __y) 3490{ 3491 typedef typename _Expr1::value_type value_type; 3492 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op; 3493 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y)); 3494} 3495 3496template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3497inline _LIBCPP_HIDE_FROM_ABI 3498__val_expr<_BinaryOp<minus<typename _Expr::value_type>, 3499 _Expr, __scalar_expr<typename _Expr::value_type> > > 3500operator-(const _Expr& __x, const typename _Expr::value_type& __y) 3501{ 3502 typedef typename _Expr::value_type value_type; 3503 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3504 return __val_expr<_Op>(_Op(minus<value_type>(), 3505 __x, __scalar_expr<value_type>(__y, __x.size()))); 3506} 3507 3508template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3509inline _LIBCPP_HIDE_FROM_ABI 3510__val_expr<_BinaryOp<minus<typename _Expr::value_type>, 3511 __scalar_expr<typename _Expr::value_type>, _Expr> > 3512operator-(const typename _Expr::value_type& __x, const _Expr& __y) 3513{ 3514 typedef typename _Expr::value_type value_type; 3515 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3516 return __val_expr<_Op>(_Op(minus<value_type>(), 3517 __scalar_expr<value_type>(__x, __y.size()), __y)); 3518} 3519 3520template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3521inline _LIBCPP_HIDE_FROM_ABI 3522__val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> > 3523operator^(const _Expr1& __x, const _Expr2& __y) 3524{ 3525 typedef typename _Expr1::value_type value_type; 3526 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op; 3527 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y)); 3528} 3529 3530template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3531inline _LIBCPP_HIDE_FROM_ABI 3532__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, 3533 _Expr, __scalar_expr<typename _Expr::value_type> > > 3534operator^(const _Expr& __x, const typename _Expr::value_type& __y) 3535{ 3536 typedef typename _Expr::value_type value_type; 3537 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3538 return __val_expr<_Op>(_Op(bit_xor<value_type>(), 3539 __x, __scalar_expr<value_type>(__y, __x.size()))); 3540} 3541 3542template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3543inline _LIBCPP_HIDE_FROM_ABI 3544__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, 3545 __scalar_expr<typename _Expr::value_type>, _Expr> > 3546operator^(const typename _Expr::value_type& __x, const _Expr& __y) 3547{ 3548 typedef typename _Expr::value_type value_type; 3549 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3550 return __val_expr<_Op>(_Op(bit_xor<value_type>(), 3551 __scalar_expr<value_type>(__x, __y.size()), __y)); 3552} 3553 3554template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3555inline _LIBCPP_HIDE_FROM_ABI 3556__val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> > 3557operator&(const _Expr1& __x, const _Expr2& __y) 3558{ 3559 typedef typename _Expr1::value_type value_type; 3560 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op; 3561 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y)); 3562} 3563 3564template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3565inline _LIBCPP_HIDE_FROM_ABI 3566__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, 3567 _Expr, __scalar_expr<typename _Expr::value_type> > > 3568operator&(const _Expr& __x, const typename _Expr::value_type& __y) 3569{ 3570 typedef typename _Expr::value_type value_type; 3571 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3572 return __val_expr<_Op>(_Op(bit_and<value_type>(), 3573 __x, __scalar_expr<value_type>(__y, __x.size()))); 3574} 3575 3576template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3577inline _LIBCPP_HIDE_FROM_ABI 3578__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, 3579 __scalar_expr<typename _Expr::value_type>, _Expr> > 3580operator&(const typename _Expr::value_type& __x, const _Expr& __y) 3581{ 3582 typedef typename _Expr::value_type value_type; 3583 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3584 return __val_expr<_Op>(_Op(bit_and<value_type>(), 3585 __scalar_expr<value_type>(__x, __y.size()), __y)); 3586} 3587 3588template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3589inline _LIBCPP_HIDE_FROM_ABI 3590__val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> > 3591operator|(const _Expr1& __x, const _Expr2& __y) 3592{ 3593 typedef typename _Expr1::value_type value_type; 3594 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op; 3595 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y)); 3596} 3597 3598template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3599inline _LIBCPP_HIDE_FROM_ABI 3600__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, 3601 _Expr, __scalar_expr<typename _Expr::value_type> > > 3602operator|(const _Expr& __x, const typename _Expr::value_type& __y) 3603{ 3604 typedef typename _Expr::value_type value_type; 3605 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3606 return __val_expr<_Op>(_Op(bit_or<value_type>(), 3607 __x, __scalar_expr<value_type>(__y, __x.size()))); 3608} 3609 3610template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3611inline _LIBCPP_HIDE_FROM_ABI 3612__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, 3613 __scalar_expr<typename _Expr::value_type>, _Expr> > 3614operator|(const typename _Expr::value_type& __x, const _Expr& __y) 3615{ 3616 typedef typename _Expr::value_type value_type; 3617 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3618 return __val_expr<_Op>(_Op(bit_or<value_type>(), 3619 __scalar_expr<value_type>(__x, __y.size()), __y)); 3620} 3621 3622template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3623inline _LIBCPP_HIDE_FROM_ABI 3624__val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> > 3625operator<<(const _Expr1& __x, const _Expr2& __y) 3626{ 3627 typedef typename _Expr1::value_type value_type; 3628 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op; 3629 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y)); 3630} 3631 3632template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3633inline _LIBCPP_HIDE_FROM_ABI 3634__val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, 3635 _Expr, __scalar_expr<typename _Expr::value_type> > > 3636operator<<(const _Expr& __x, const typename _Expr::value_type& __y) 3637{ 3638 typedef typename _Expr::value_type value_type; 3639 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3640 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), 3641 __x, __scalar_expr<value_type>(__y, __x.size()))); 3642} 3643 3644template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3645inline _LIBCPP_HIDE_FROM_ABI 3646__val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, 3647 __scalar_expr<typename _Expr::value_type>, _Expr> > 3648operator<<(const typename _Expr::value_type& __x, const _Expr& __y) 3649{ 3650 typedef typename _Expr::value_type value_type; 3651 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3652 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), 3653 __scalar_expr<value_type>(__x, __y.size()), __y)); 3654} 3655 3656template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3657inline _LIBCPP_HIDE_FROM_ABI 3658__val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> > 3659operator>>(const _Expr1& __x, const _Expr2& __y) 3660{ 3661 typedef typename _Expr1::value_type value_type; 3662 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op; 3663 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y)); 3664} 3665 3666template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3667inline _LIBCPP_HIDE_FROM_ABI 3668__val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, 3669 _Expr, __scalar_expr<typename _Expr::value_type> > > 3670operator>>(const _Expr& __x, const typename _Expr::value_type& __y) 3671{ 3672 typedef typename _Expr::value_type value_type; 3673 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3674 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), 3675 __x, __scalar_expr<value_type>(__y, __x.size()))); 3676} 3677 3678template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3679inline _LIBCPP_HIDE_FROM_ABI 3680__val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, 3681 __scalar_expr<typename _Expr::value_type>, _Expr> > 3682operator>>(const typename _Expr::value_type& __x, const _Expr& __y) 3683{ 3684 typedef typename _Expr::value_type value_type; 3685 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3686 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), 3687 __scalar_expr<value_type>(__x, __y.size()), __y)); 3688} 3689 3690template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3691inline _LIBCPP_HIDE_FROM_ABI 3692__val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> > 3693operator&&(const _Expr1& __x, const _Expr2& __y) 3694{ 3695 typedef typename _Expr1::value_type value_type; 3696 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op; 3697 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y)); 3698} 3699 3700template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3701inline _LIBCPP_HIDE_FROM_ABI 3702__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, 3703 _Expr, __scalar_expr<typename _Expr::value_type> > > 3704operator&&(const _Expr& __x, const typename _Expr::value_type& __y) 3705{ 3706 typedef typename _Expr::value_type value_type; 3707 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3708 return __val_expr<_Op>(_Op(logical_and<value_type>(), 3709 __x, __scalar_expr<value_type>(__y, __x.size()))); 3710} 3711 3712template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3713inline _LIBCPP_HIDE_FROM_ABI 3714__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, 3715 __scalar_expr<typename _Expr::value_type>, _Expr> > 3716operator&&(const typename _Expr::value_type& __x, const _Expr& __y) 3717{ 3718 typedef typename _Expr::value_type value_type; 3719 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3720 return __val_expr<_Op>(_Op(logical_and<value_type>(), 3721 __scalar_expr<value_type>(__x, __y.size()), __y)); 3722} 3723 3724template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3725inline _LIBCPP_HIDE_FROM_ABI 3726__val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> > 3727operator||(const _Expr1& __x, const _Expr2& __y) 3728{ 3729 typedef typename _Expr1::value_type value_type; 3730 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op; 3731 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y)); 3732} 3733 3734template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3735inline _LIBCPP_HIDE_FROM_ABI 3736__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, 3737 _Expr, __scalar_expr<typename _Expr::value_type> > > 3738operator||(const _Expr& __x, const typename _Expr::value_type& __y) 3739{ 3740 typedef typename _Expr::value_type value_type; 3741 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3742 return __val_expr<_Op>(_Op(logical_or<value_type>(), 3743 __x, __scalar_expr<value_type>(__y, __x.size()))); 3744} 3745 3746template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3747inline _LIBCPP_HIDE_FROM_ABI 3748__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, 3749 __scalar_expr<typename _Expr::value_type>, _Expr> > 3750operator||(const typename _Expr::value_type& __x, const _Expr& __y) 3751{ 3752 typedef typename _Expr::value_type value_type; 3753 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3754 return __val_expr<_Op>(_Op(logical_or<value_type>(), 3755 __scalar_expr<value_type>(__x, __y.size()), __y)); 3756} 3757 3758template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3759inline _LIBCPP_HIDE_FROM_ABI 3760__val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > 3761operator==(const _Expr1& __x, const _Expr2& __y) 3762{ 3763 typedef typename _Expr1::value_type value_type; 3764 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op; 3765 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y)); 3766} 3767 3768template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3769inline _LIBCPP_HIDE_FROM_ABI 3770__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, 3771 _Expr, __scalar_expr<typename _Expr::value_type> > > 3772operator==(const _Expr& __x, const typename _Expr::value_type& __y) 3773{ 3774 typedef typename _Expr::value_type value_type; 3775 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3776 return __val_expr<_Op>(_Op(equal_to<value_type>(), 3777 __x, __scalar_expr<value_type>(__y, __x.size()))); 3778} 3779 3780template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3781inline _LIBCPP_HIDE_FROM_ABI 3782__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, 3783 __scalar_expr<typename _Expr::value_type>, _Expr> > 3784operator==(const typename _Expr::value_type& __x, const _Expr& __y) 3785{ 3786 typedef typename _Expr::value_type value_type; 3787 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3788 return __val_expr<_Op>(_Op(equal_to<value_type>(), 3789 __scalar_expr<value_type>(__x, __y.size()), __y)); 3790} 3791 3792template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3793inline _LIBCPP_HIDE_FROM_ABI 3794__val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > 3795operator!=(const _Expr1& __x, const _Expr2& __y) 3796{ 3797 typedef typename _Expr1::value_type value_type; 3798 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op; 3799 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y)); 3800} 3801 3802template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3803inline _LIBCPP_HIDE_FROM_ABI 3804__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, 3805 _Expr, __scalar_expr<typename _Expr::value_type> > > 3806operator!=(const _Expr& __x, const typename _Expr::value_type& __y) 3807{ 3808 typedef typename _Expr::value_type value_type; 3809 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3810 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), 3811 __x, __scalar_expr<value_type>(__y, __x.size()))); 3812} 3813 3814template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3815inline _LIBCPP_HIDE_FROM_ABI 3816__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, 3817 __scalar_expr<typename _Expr::value_type>, _Expr> > 3818operator!=(const typename _Expr::value_type& __x, const _Expr& __y) 3819{ 3820 typedef typename _Expr::value_type value_type; 3821 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3822 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), 3823 __scalar_expr<value_type>(__x, __y.size()), __y)); 3824} 3825 3826template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3827inline _LIBCPP_HIDE_FROM_ABI 3828__val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> > 3829operator<(const _Expr1& __x, const _Expr2& __y) 3830{ 3831 typedef typename _Expr1::value_type value_type; 3832 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op; 3833 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y)); 3834} 3835 3836template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3837inline _LIBCPP_HIDE_FROM_ABI 3838__val_expr<_BinaryOp<less<typename _Expr::value_type>, 3839 _Expr, __scalar_expr<typename _Expr::value_type> > > 3840operator<(const _Expr& __x, const typename _Expr::value_type& __y) 3841{ 3842 typedef typename _Expr::value_type value_type; 3843 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3844 return __val_expr<_Op>(_Op(less<value_type>(), 3845 __x, __scalar_expr<value_type>(__y, __x.size()))); 3846} 3847 3848template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3849inline _LIBCPP_HIDE_FROM_ABI 3850__val_expr<_BinaryOp<less<typename _Expr::value_type>, 3851 __scalar_expr<typename _Expr::value_type>, _Expr> > 3852operator<(const typename _Expr::value_type& __x, const _Expr& __y) 3853{ 3854 typedef typename _Expr::value_type value_type; 3855 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3856 return __val_expr<_Op>(_Op(less<value_type>(), 3857 __scalar_expr<value_type>(__x, __y.size()), __y)); 3858} 3859 3860template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3861inline _LIBCPP_HIDE_FROM_ABI 3862__val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> > 3863operator>(const _Expr1& __x, const _Expr2& __y) 3864{ 3865 typedef typename _Expr1::value_type value_type; 3866 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op; 3867 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y)); 3868} 3869 3870template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3871inline _LIBCPP_HIDE_FROM_ABI 3872__val_expr<_BinaryOp<greater<typename _Expr::value_type>, 3873 _Expr, __scalar_expr<typename _Expr::value_type> > > 3874operator>(const _Expr& __x, const typename _Expr::value_type& __y) 3875{ 3876 typedef typename _Expr::value_type value_type; 3877 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3878 return __val_expr<_Op>(_Op(greater<value_type>(), 3879 __x, __scalar_expr<value_type>(__y, __x.size()))); 3880} 3881 3882template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3883inline _LIBCPP_HIDE_FROM_ABI 3884__val_expr<_BinaryOp<greater<typename _Expr::value_type>, 3885 __scalar_expr<typename _Expr::value_type>, _Expr> > 3886operator>(const typename _Expr::value_type& __x, const _Expr& __y) 3887{ 3888 typedef typename _Expr::value_type value_type; 3889 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3890 return __val_expr<_Op>(_Op(greater<value_type>(), 3891 __scalar_expr<value_type>(__x, __y.size()), __y)); 3892} 3893 3894template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3895inline _LIBCPP_HIDE_FROM_ABI 3896__val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > 3897operator<=(const _Expr1& __x, const _Expr2& __y) 3898{ 3899 typedef typename _Expr1::value_type value_type; 3900 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op; 3901 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y)); 3902} 3903 3904template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3905inline _LIBCPP_HIDE_FROM_ABI 3906__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, 3907 _Expr, __scalar_expr<typename _Expr::value_type> > > 3908operator<=(const _Expr& __x, const typename _Expr::value_type& __y) 3909{ 3910 typedef typename _Expr::value_type value_type; 3911 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3912 return __val_expr<_Op>(_Op(less_equal<value_type>(), 3913 __x, __scalar_expr<value_type>(__y, __x.size()))); 3914} 3915 3916template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3917inline _LIBCPP_HIDE_FROM_ABI 3918__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, 3919 __scalar_expr<typename _Expr::value_type>, _Expr> > 3920operator<=(const typename _Expr::value_type& __x, const _Expr& __y) 3921{ 3922 typedef typename _Expr::value_type value_type; 3923 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3924 return __val_expr<_Op>(_Op(less_equal<value_type>(), 3925 __scalar_expr<value_type>(__x, __y.size()), __y)); 3926} 3927 3928template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 3929inline _LIBCPP_HIDE_FROM_ABI 3930__val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > 3931operator>=(const _Expr1& __x, const _Expr2& __y) 3932{ 3933 typedef typename _Expr1::value_type value_type; 3934 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op; 3935 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y)); 3936} 3937 3938template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3939inline _LIBCPP_HIDE_FROM_ABI 3940__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, 3941 _Expr, __scalar_expr<typename _Expr::value_type> > > 3942operator>=(const _Expr& __x, const typename _Expr::value_type& __y) 3943{ 3944 typedef typename _Expr::value_type value_type; 3945 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3946 return __val_expr<_Op>(_Op(greater_equal<value_type>(), 3947 __x, __scalar_expr<value_type>(__y, __x.size()))); 3948} 3949 3950template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3951inline _LIBCPP_HIDE_FROM_ABI 3952__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, 3953 __scalar_expr<typename _Expr::value_type>, _Expr> > 3954operator>=(const typename _Expr::value_type& __x, const _Expr& __y) 3955{ 3956 typedef typename _Expr::value_type value_type; 3957 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3958 return __val_expr<_Op>(_Op(greater_equal<value_type>(), 3959 __scalar_expr<value_type>(__x, __y.size()), __y)); 3960} 3961 3962template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3963inline _LIBCPP_HIDE_FROM_ABI 3964__val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > 3965abs(const _Expr& __x) 3966{ 3967 typedef typename _Expr::value_type value_type; 3968 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op; 3969 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x)); 3970} 3971 3972template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3973inline _LIBCPP_HIDE_FROM_ABI 3974__val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > 3975acos(const _Expr& __x) 3976{ 3977 typedef typename _Expr::value_type value_type; 3978 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op; 3979 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x)); 3980} 3981 3982template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3983inline _LIBCPP_HIDE_FROM_ABI 3984__val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > 3985asin(const _Expr& __x) 3986{ 3987 typedef typename _Expr::value_type value_type; 3988 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op; 3989 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x)); 3990} 3991 3992template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 3993inline _LIBCPP_HIDE_FROM_ABI 3994__val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > 3995atan(const _Expr& __x) 3996{ 3997 typedef typename _Expr::value_type value_type; 3998 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op; 3999 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x)); 4000} 4001 4002template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 4003inline _LIBCPP_HIDE_FROM_ABI 4004__val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > 4005atan2(const _Expr1& __x, const _Expr2& __y) 4006{ 4007 typedef typename _Expr1::value_type value_type; 4008 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op; 4009 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); 4010} 4011 4012template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4013inline _LIBCPP_HIDE_FROM_ABI 4014 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, 4015 _Expr, __scalar_expr<typename _Expr::value_type> > > 4016atan2(const _Expr& __x, const typename _Expr::value_type& __y) 4017{ 4018 typedef typename _Expr::value_type value_type; 4019 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4020 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), 4021 __x, __scalar_expr<value_type>(__y, __x.size()))); 4022} 4023 4024template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4025inline _LIBCPP_HIDE_FROM_ABI 4026 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, 4027 __scalar_expr<typename _Expr::value_type>, _Expr> > 4028atan2(const typename _Expr::value_type& __x, const _Expr& __y) 4029{ 4030 typedef typename _Expr::value_type value_type; 4031 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4032 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), 4033 __scalar_expr<value_type>(__x, __y.size()), __y)); 4034} 4035 4036template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4037inline _LIBCPP_HIDE_FROM_ABI 4038__val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > 4039cos(const _Expr& __x) 4040{ 4041 typedef typename _Expr::value_type value_type; 4042 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op; 4043 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x)); 4044} 4045 4046template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4047inline _LIBCPP_HIDE_FROM_ABI 4048__val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > 4049cosh(const _Expr& __x) 4050{ 4051 typedef typename _Expr::value_type value_type; 4052 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op; 4053 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x)); 4054} 4055 4056template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4057inline _LIBCPP_HIDE_FROM_ABI 4058__val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > 4059exp(const _Expr& __x) 4060{ 4061 typedef typename _Expr::value_type value_type; 4062 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op; 4063 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x)); 4064} 4065 4066template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4067inline _LIBCPP_HIDE_FROM_ABI 4068__val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > 4069log(const _Expr& __x) 4070{ 4071 typedef typename _Expr::value_type value_type; 4072 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op; 4073 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x)); 4074} 4075 4076template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4077inline _LIBCPP_HIDE_FROM_ABI 4078__val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > 4079log10(const _Expr& __x) 4080{ 4081 typedef typename _Expr::value_type value_type; 4082 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op; 4083 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x)); 4084} 4085 4086template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> 4087inline _LIBCPP_HIDE_FROM_ABI 4088__val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > 4089pow(const _Expr1& __x, const _Expr2& __y) 4090{ 4091 typedef typename _Expr1::value_type value_type; 4092 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op; 4093 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); 4094} 4095 4096template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4097inline _LIBCPP_HIDE_FROM_ABI 4098__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, 4099 _Expr, __scalar_expr<typename _Expr::value_type> > > 4100pow(const _Expr& __x, const typename _Expr::value_type& __y) 4101{ 4102 typedef typename _Expr::value_type value_type; 4103 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4104 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), 4105 __x, __scalar_expr<value_type>(__y, __x.size()))); 4106} 4107 4108template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4109inline _LIBCPP_HIDE_FROM_ABI 4110__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, 4111 __scalar_expr<typename _Expr::value_type>, _Expr> > 4112pow(const typename _Expr::value_type& __x, const _Expr& __y) 4113{ 4114 typedef typename _Expr::value_type value_type; 4115 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4116 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), 4117 __scalar_expr<value_type>(__x, __y.size()), __y)); 4118} 4119 4120template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4121inline _LIBCPP_HIDE_FROM_ABI 4122 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > 4123sin(const _Expr& __x) 4124{ 4125 typedef typename _Expr::value_type value_type; 4126 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op; 4127 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x)); 4128} 4129 4130template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4131inline _LIBCPP_HIDE_FROM_ABI 4132 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > 4133sinh(const _Expr& __x) 4134{ 4135 typedef typename _Expr::value_type value_type; 4136 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op; 4137 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x)); 4138} 4139 4140template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4141inline _LIBCPP_HIDE_FROM_ABI 4142 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > 4143sqrt(const _Expr& __x) 4144{ 4145 typedef typename _Expr::value_type value_type; 4146 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op; 4147 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x)); 4148} 4149 4150template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4151inline _LIBCPP_HIDE_FROM_ABI 4152 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > 4153tan(const _Expr& __x) 4154{ 4155 typedef typename _Expr::value_type value_type; 4156 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op; 4157 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x)); 4158} 4159 4160template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> 4161inline _LIBCPP_HIDE_FROM_ABI 4162 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > 4163tanh(const _Expr& __x) 4164{ 4165 typedef typename _Expr::value_type value_type; 4166 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op; 4167 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x)); 4168} 4169 4170template <class _Tp> 4171inline _LIBCPP_HIDE_FROM_ABI 4172_Tp* 4173begin(valarray<_Tp>& __v) 4174{ 4175 return __v.__begin_; 4176} 4177 4178template <class _Tp> 4179inline _LIBCPP_HIDE_FROM_ABI 4180const _Tp* 4181begin(const valarray<_Tp>& __v) 4182{ 4183 return __v.__begin_; 4184} 4185 4186template <class _Tp> 4187inline _LIBCPP_HIDE_FROM_ABI 4188_Tp* 4189end(valarray<_Tp>& __v) 4190{ 4191 return __v.__end_; 4192} 4193 4194template <class _Tp> 4195inline _LIBCPP_HIDE_FROM_ABI 4196const _Tp* 4197end(const valarray<_Tp>& __v) 4198{ 4199 return __v.__end_; 4200} 4201 4202_LIBCPP_END_NAMESPACE_STD 4203 4204_LIBCPP_POP_MACROS 4205 4206#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 4207# include <algorithm> 4208# include <concepts> 4209# include <cstdlib> 4210# include <cstring> 4211# include <functional> 4212# include <stdexcept> 4213# include <type_traits> 4214#endif 4215 4216#endif // _LIBCPP_VALARRAY 4217