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