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