Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_VALARRAY |
| 11 | #define _LIBCPP_VALARRAY |
| 12 | |
| 13 | /* |
| 14 | valarray synopsis |
| 15 | |
| 16 | namespace std |
| 17 | { |
| 18 | |
| 19 | template<class T> |
| 20 | class valarray |
| 21 | { |
| 22 | public: |
| 23 | typedef T value_type; |
| 24 | |
| 25 | // construct/destroy: |
| 26 | valarray(); |
| 27 | explicit valarray(size_t n); |
| 28 | valarray(const value_type& x, size_t n); |
| 29 | valarray(const value_type* px, size_t n); |
| 30 | valarray(const valarray& v); |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 31 | valarray(valarray&& v) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 32 | valarray(const slice_array<value_type>& sa); |
| 33 | valarray(const gslice_array<value_type>& ga); |
| 34 | valarray(const mask_array<value_type>& ma); |
| 35 | valarray(const indirect_array<value_type>& ia); |
| 36 | valarray(initializer_list<value_type> il); |
| 37 | ~valarray(); |
| 38 | |
| 39 | // assignment: |
| 40 | valarray& operator=(const valarray& v); |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 41 | valarray& operator=(valarray&& v) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 42 | valarray& operator=(initializer_list<value_type> il); |
| 43 | valarray& operator=(const value_type& x); |
| 44 | valarray& operator=(const slice_array<value_type>& sa); |
| 45 | valarray& operator=(const gslice_array<value_type>& ga); |
| 46 | valarray& operator=(const mask_array<value_type>& ma); |
| 47 | valarray& operator=(const indirect_array<value_type>& ia); |
| 48 | |
| 49 | // element access: |
| 50 | const value_type& operator[](size_t i) const; |
| 51 | value_type& operator[](size_t i); |
| 52 | |
| 53 | // subset operations: |
| 54 | valarray operator[](slice s) const; |
| 55 | slice_array<value_type> operator[](slice s); |
| 56 | valarray operator[](const gslice& gs) const; |
| 57 | gslice_array<value_type> operator[](const gslice& gs); |
| 58 | valarray operator[](const valarray<bool>& vb) const; |
| 59 | mask_array<value_type> operator[](const valarray<bool>& vb); |
| 60 | valarray operator[](const valarray<size_t>& vs) const; |
| 61 | indirect_array<value_type> operator[](const valarray<size_t>& vs); |
| 62 | |
| 63 | // unary operators: |
| 64 | valarray operator+() const; |
| 65 | valarray operator-() const; |
| 66 | valarray operator~() const; |
| 67 | valarray<bool> operator!() const; |
| 68 | |
| 69 | // computed assignment: |
| 70 | valarray& operator*= (const value_type& x); |
| 71 | valarray& operator/= (const value_type& x); |
| 72 | valarray& operator%= (const value_type& x); |
| 73 | valarray& operator+= (const value_type& x); |
| 74 | valarray& operator-= (const value_type& x); |
| 75 | valarray& operator^= (const value_type& x); |
| 76 | valarray& operator&= (const value_type& x); |
| 77 | valarray& operator|= (const value_type& x); |
| 78 | valarray& operator<<=(const value_type& x); |
| 79 | valarray& operator>>=(const value_type& x); |
| 80 | |
| 81 | valarray& operator*= (const valarray& v); |
| 82 | valarray& operator/= (const valarray& v); |
| 83 | valarray& operator%= (const valarray& v); |
| 84 | valarray& operator+= (const valarray& v); |
| 85 | valarray& operator-= (const valarray& v); |
| 86 | valarray& operator^= (const valarray& v); |
| 87 | valarray& operator|= (const valarray& v); |
| 88 | valarray& operator&= (const valarray& v); |
| 89 | valarray& operator<<=(const valarray& v); |
| 90 | valarray& operator>>=(const valarray& v); |
| 91 | |
| 92 | // member functions: |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 93 | void swap(valarray& v) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 94 | |
| 95 | size_t size() const; |
| 96 | |
| 97 | value_type sum() const; |
| 98 | value_type min() const; |
| 99 | value_type max() const; |
| 100 | |
| 101 | valarray shift (int i) const; |
| 102 | valarray cshift(int i) const; |
| 103 | valarray apply(value_type f(value_type)) const; |
| 104 | valarray apply(value_type f(const value_type&)) const; |
| 105 | void resize(size_t n, value_type x = value_type()); |
| 106 | }; |
| 107 | |
Konstantin Varlamov | ebb3119 | 2021-10-28 00:36:19 -0700 | [diff] [blame] | 108 | template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>; |
| 109 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 110 | class slice |
| 111 | { |
| 112 | public: |
| 113 | slice(); |
| 114 | slice(size_t start, size_t size, size_t stride); |
| 115 | |
| 116 | size_t start() const; |
| 117 | size_t size() const; |
| 118 | size_t stride() const; |
| 119 | }; |
| 120 | |
| 121 | template <class T> |
| 122 | class slice_array |
| 123 | { |
| 124 | public: |
| 125 | typedef T value_type; |
| 126 | |
| 127 | const slice_array& operator=(const slice_array& sa) const; |
| 128 | void operator= (const valarray<value_type>& v) const; |
| 129 | void operator*= (const valarray<value_type>& v) const; |
| 130 | void operator/= (const valarray<value_type>& v) const; |
| 131 | void operator%= (const valarray<value_type>& v) const; |
| 132 | void operator+= (const valarray<value_type>& v) const; |
| 133 | void operator-= (const valarray<value_type>& v) const; |
| 134 | void operator^= (const valarray<value_type>& v) const; |
| 135 | void operator&= (const valarray<value_type>& v) const; |
| 136 | void operator|= (const valarray<value_type>& v) const; |
| 137 | void operator<<=(const valarray<value_type>& v) const; |
| 138 | void operator>>=(const valarray<value_type>& v) const; |
| 139 | |
| 140 | void operator=(const value_type& x) const; |
zoecarver | 79fa750 | 2020-12-02 10:49:20 -0800 | [diff] [blame] | 141 | void operator=(const valarray<T>& val_arr) const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 142 | |
| 143 | slice_array() = delete; |
| 144 | }; |
| 145 | |
| 146 | class gslice |
| 147 | { |
| 148 | public: |
| 149 | gslice(); |
| 150 | gslice(size_t start, const valarray<size_t>& size, |
| 151 | const valarray<size_t>& stride); |
| 152 | |
| 153 | size_t start() const; |
| 154 | valarray<size_t> size() const; |
| 155 | valarray<size_t> stride() const; |
| 156 | }; |
| 157 | |
| 158 | template <class T> |
| 159 | class gslice_array |
| 160 | { |
| 161 | public: |
| 162 | typedef T value_type; |
| 163 | |
| 164 | void operator= (const valarray<value_type>& v) const; |
| 165 | void operator*= (const valarray<value_type>& v) const; |
| 166 | void operator/= (const valarray<value_type>& v) const; |
| 167 | void operator%= (const valarray<value_type>& v) const; |
| 168 | void operator+= (const valarray<value_type>& v) const; |
| 169 | void operator-= (const valarray<value_type>& v) const; |
| 170 | void operator^= (const valarray<value_type>& v) const; |
| 171 | void operator&= (const valarray<value_type>& v) const; |
| 172 | void operator|= (const valarray<value_type>& v) const; |
| 173 | void operator<<=(const valarray<value_type>& v) const; |
| 174 | void operator>>=(const valarray<value_type>& v) const; |
| 175 | |
| 176 | gslice_array(const gslice_array& ga); |
| 177 | ~gslice_array(); |
| 178 | const gslice_array& operator=(const gslice_array& ga) const; |
| 179 | void operator=(const value_type& x) const; |
| 180 | |
| 181 | gslice_array() = delete; |
| 182 | }; |
| 183 | |
| 184 | template <class T> |
| 185 | class mask_array |
| 186 | { |
| 187 | public: |
| 188 | typedef T value_type; |
| 189 | |
| 190 | void operator= (const valarray<value_type>& v) const; |
| 191 | void operator*= (const valarray<value_type>& v) const; |
| 192 | void operator/= (const valarray<value_type>& v) const; |
| 193 | void operator%= (const valarray<value_type>& v) const; |
| 194 | void operator+= (const valarray<value_type>& v) const; |
| 195 | void operator-= (const valarray<value_type>& v) const; |
| 196 | void operator^= (const valarray<value_type>& v) const; |
| 197 | void operator&= (const valarray<value_type>& v) const; |
| 198 | void operator|= (const valarray<value_type>& v) const; |
| 199 | void operator<<=(const valarray<value_type>& v) const; |
| 200 | void operator>>=(const valarray<value_type>& v) const; |
| 201 | |
| 202 | mask_array(const mask_array& ma); |
| 203 | ~mask_array(); |
| 204 | const mask_array& operator=(const mask_array& ma) const; |
| 205 | void operator=(const value_type& x) const; |
| 206 | |
| 207 | mask_array() = delete; |
| 208 | }; |
| 209 | |
| 210 | template <class T> |
| 211 | class indirect_array |
| 212 | { |
| 213 | public: |
| 214 | typedef T value_type; |
| 215 | |
| 216 | void operator= (const valarray<value_type>& v) const; |
| 217 | void operator*= (const valarray<value_type>& v) const; |
| 218 | void operator/= (const valarray<value_type>& v) const; |
| 219 | void operator%= (const valarray<value_type>& v) const; |
| 220 | void operator+= (const valarray<value_type>& v) const; |
| 221 | void operator-= (const valarray<value_type>& v) const; |
| 222 | void operator^= (const valarray<value_type>& v) const; |
| 223 | void operator&= (const valarray<value_type>& v) const; |
| 224 | void operator|= (const valarray<value_type>& v) const; |
| 225 | void operator<<=(const valarray<value_type>& v) const; |
| 226 | void operator>>=(const valarray<value_type>& v) const; |
| 227 | |
| 228 | indirect_array(const indirect_array& ia); |
| 229 | ~indirect_array(); |
| 230 | const indirect_array& operator=(const indirect_array& ia) const; |
| 231 | void operator=(const value_type& x) const; |
| 232 | |
| 233 | indirect_array() = delete; |
| 234 | }; |
| 235 | |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 236 | template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 237 | |
| 238 | template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y); |
| 239 | template<class T> valarray<T> operator* (const valarray<T>& x, const T& y); |
| 240 | template<class T> valarray<T> operator* (const T& x, const valarray<T>& y); |
| 241 | |
| 242 | template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y); |
| 243 | template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y); |
| 244 | template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y); |
| 245 | |
| 246 | template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y); |
| 247 | template<class T> valarray<T> operator% (const valarray<T>& x, const T& y); |
| 248 | template<class T> valarray<T> operator% (const T& x, const valarray<T>& y); |
| 249 | |
| 250 | template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y); |
| 251 | template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y); |
| 252 | template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y); |
| 253 | |
| 254 | template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y); |
| 255 | template<class T> valarray<T> operator- (const valarray<T>& x, const T& y); |
| 256 | template<class T> valarray<T> operator- (const T& x, const valarray<T>& y); |
| 257 | |
| 258 | template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y); |
| 259 | template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y); |
| 260 | template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y); |
| 261 | |
| 262 | template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y); |
| 263 | template<class T> valarray<T> operator& (const valarray<T>& x, const T& y); |
| 264 | template<class T> valarray<T> operator& (const T& x, const valarray<T>& y); |
| 265 | |
| 266 | template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y); |
| 267 | template<class T> valarray<T> operator| (const valarray<T>& x, const T& y); |
| 268 | template<class T> valarray<T> operator| (const T& x, const valarray<T>& y); |
| 269 | |
| 270 | template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y); |
| 271 | template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y); |
| 272 | template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y); |
| 273 | |
| 274 | template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y); |
| 275 | template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y); |
| 276 | template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y); |
| 277 | |
| 278 | template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y); |
| 279 | template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y); |
| 280 | template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y); |
| 281 | |
| 282 | template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y); |
| 283 | template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y); |
| 284 | template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y); |
| 285 | |
| 286 | template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y); |
| 287 | template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y); |
| 288 | template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y); |
| 289 | |
| 290 | template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y); |
| 291 | template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y); |
| 292 | template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y); |
| 293 | |
| 294 | template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y); |
| 295 | template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y); |
| 296 | template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y); |
| 297 | |
| 298 | template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y); |
| 299 | template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y); |
| 300 | template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y); |
| 301 | |
| 302 | template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y); |
| 303 | template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y); |
| 304 | template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y); |
| 305 | |
| 306 | template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y); |
| 307 | template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y); |
| 308 | template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y); |
| 309 | |
| 310 | template<class T> valarray<T> abs (const valarray<T>& x); |
| 311 | template<class T> valarray<T> acos (const valarray<T>& x); |
| 312 | template<class T> valarray<T> asin (const valarray<T>& x); |
| 313 | template<class T> valarray<T> atan (const valarray<T>& x); |
| 314 | |
| 315 | template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y); |
| 316 | template<class T> valarray<T> atan2(const valarray<T>& x, const T& y); |
| 317 | template<class T> valarray<T> atan2(const T& x, const valarray<T>& y); |
| 318 | |
| 319 | template<class T> valarray<T> cos (const valarray<T>& x); |
| 320 | template<class T> valarray<T> cosh (const valarray<T>& x); |
| 321 | template<class T> valarray<T> exp (const valarray<T>& x); |
| 322 | template<class T> valarray<T> log (const valarray<T>& x); |
| 323 | template<class T> valarray<T> log10(const valarray<T>& x); |
| 324 | |
| 325 | template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y); |
| 326 | template<class T> valarray<T> pow(const valarray<T>& x, const T& y); |
| 327 | template<class T> valarray<T> pow(const T& x, const valarray<T>& y); |
| 328 | |
| 329 | template<class T> valarray<T> sin (const valarray<T>& x); |
| 330 | template<class T> valarray<T> sinh (const valarray<T>& x); |
| 331 | template<class T> valarray<T> sqrt (const valarray<T>& x); |
| 332 | template<class T> valarray<T> tan (const valarray<T>& x); |
| 333 | template<class T> valarray<T> tanh (const valarray<T>& x); |
| 334 | |
| 335 | template <class T> unspecified1 begin(valarray<T>& v); |
| 336 | template <class T> unspecified2 begin(const valarray<T>& v); |
| 337 | template <class T> unspecified1 end(valarray<T>& v); |
| 338 | template <class T> unspecified2 end(const valarray<T>& v); |
| 339 | |
| 340 | } // std |
| 341 | |
| 342 | */ |
| 343 | |
Nikolas Klauser | f210d8a | 2022-02-15 18:18:08 +0100 | [diff] [blame] | 344 | #include <__algorithm/copy.h> |
| 345 | #include <__algorithm/count.h> |
| 346 | #include <__algorithm/fill.h> |
| 347 | #include <__algorithm/max_element.h> |
| 348 | #include <__algorithm/min.h> |
| 349 | #include <__algorithm/min_element.h> |
| 350 | #include <__algorithm/unwrap_iter.h> |
Louis Dionne | b4fce35 | 2022-03-25 12:55:36 -0400 | [diff] [blame] | 351 | #include <__assert> // all public C++ headers provide the assertion handler |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 352 | #include <__config> |
Nikolas Klauser | ee2dbc3 | 2022-04-17 16:01:38 +0200 | [diff] [blame] | 353 | #include <__functional/operations.h> |
| 354 | #include <__memory/allocator.h> |
| 355 | #include <__memory/uninitialized_algorithms.h> |
Nikolas Klauser | ca7ac53 | 2022-12-21 00:07:17 +0100 | [diff] [blame] | 356 | #include <__type_traits/remove_reference.h> |
Nikolas Klauser | ee2dbc3 | 2022-04-17 16:01:38 +0200 | [diff] [blame] | 357 | #include <__utility/move.h> |
| 358 | #include <__utility/swap.h> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 359 | #include <cmath> |
| 360 | #include <cstddef> |
Richard Smith | 1f1c147 | 2014-06-04 19:54:15 +0000 | [diff] [blame] | 361 | #include <new> |
Mark de Wever | ce8f12c | 2021-12-22 18:14:14 +0100 | [diff] [blame] | 362 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 363 | |
Nikolas Klauser | a0e0edb | 2022-06-16 22:43:46 +0200 | [diff] [blame] | 364 | // standard-mandated includes |
Nikolas Klauser | 71619e7 | 2022-09-22 18:05:08 +0200 | [diff] [blame] | 365 | |
| 366 | // [valarray.syn] |
Nikolas Klauser | a0e0edb | 2022-06-16 22:43:46 +0200 | [diff] [blame] | 367 | #include <initializer_list> |
| 368 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 369 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Arthur O'Dwyer | 6eeaa00 | 2022-02-01 20:16:40 -0500 | [diff] [blame] | 370 | # pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 371 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 372 | |
Eric Fiselier | f4433a3 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 373 | _LIBCPP_PUSH_MACROS |
| 374 | #include <__undef_macros> |
| 375 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 376 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 377 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 378 | template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 379 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 380 | class _LIBCPP_TEMPLATE_VIS slice |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 381 | { |
| 382 | size_t __start_; |
| 383 | size_t __size_; |
| 384 | size_t __stride_; |
| 385 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 386 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 387 | slice() |
| 388 | : __start_(0), |
| 389 | __size_(0), |
| 390 | __stride_(0) |
| 391 | {} |
| 392 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 393 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 394 | slice(size_t __start, size_t __size, size_t __stride) |
| 395 | : __start_(__start), |
| 396 | __size_(__size), |
| 397 | __stride_(__stride) |
| 398 | {} |
| 399 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 400 | _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;} |
| 401 | _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} |
| 402 | _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 403 | }; |
| 404 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 405 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array; |
Howard Hinnant | 8331b76 | 2013-03-06 23:30:19 +0000 | [diff] [blame] | 406 | class _LIBCPP_TYPE_VIS gslice; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 407 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array; |
| 408 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array; |
| 409 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 410 | |
| 411 | template <class _Tp> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 412 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 413 | _Tp* |
| 414 | begin(valarray<_Tp>& __v); |
| 415 | |
| 416 | template <class _Tp> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 417 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 418 | const _Tp* |
| 419 | begin(const valarray<_Tp>& __v); |
| 420 | |
| 421 | template <class _Tp> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 422 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 423 | _Tp* |
| 424 | end(valarray<_Tp>& __v); |
| 425 | |
| 426 | template <class _Tp> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 427 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 428 | const _Tp* |
| 429 | end(const valarray<_Tp>& __v); |
| 430 | |
| 431 | template <class _Op, class _A0> |
| 432 | struct _UnaryOp |
| 433 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 434 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 435 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 436 | |
| 437 | _Op __op_; |
| 438 | _A0 __a0_; |
| 439 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 440 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 441 | _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {} |
| 442 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 443 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 444 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 445 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 446 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 447 | size_t size() const {return __a0_.size();} |
| 448 | }; |
| 449 | |
| 450 | template <class _Op, class _A0, class _A1> |
| 451 | struct _BinaryOp |
| 452 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 453 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 454 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 455 | |
| 456 | _Op __op_; |
| 457 | _A0 __a0_; |
| 458 | _A1 __a1_; |
| 459 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 460 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 461 | _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1) |
| 462 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 463 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 464 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 465 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 466 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 467 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 468 | size_t size() const {return __a0_.size();} |
| 469 | }; |
| 470 | |
| 471 | template <class _Tp> |
| 472 | class __scalar_expr |
| 473 | { |
| 474 | public: |
| 475 | typedef _Tp value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 476 | typedef const _Tp& __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 477 | private: |
| 478 | const value_type& __t_; |
| 479 | size_t __s_; |
| 480 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 481 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 482 | explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {} |
| 483 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 484 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 485 | __result_type operator[](size_t) const {return __t_;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 486 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 487 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 488 | size_t size() const {return __s_;} |
| 489 | }; |
| 490 | |
| 491 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 492 | struct __unary_plus |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 493 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 494 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 495 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 496 | _Tp operator()(const _Tp& __x) const |
| 497 | {return +__x;} |
| 498 | }; |
| 499 | |
| 500 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 501 | struct __bit_not |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 502 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 503 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 504 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 505 | _Tp operator()(const _Tp& __x) const |
| 506 | {return ~__x;} |
| 507 | }; |
| 508 | |
| 509 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 510 | struct __bit_shift_left |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 511 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 512 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 513 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 514 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 515 | {return __x << __y;} |
| 516 | }; |
| 517 | |
| 518 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 519 | struct __bit_shift_right |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 520 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 521 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 522 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 523 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 524 | {return __x >> __y;} |
| 525 | }; |
| 526 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 527 | template <class _Tp, class _Fp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 528 | struct __apply_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 529 | { |
| 530 | private: |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 531 | _Fp __f_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 532 | public: |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 533 | typedef _Tp __result_type; |
| 534 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 535 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 536 | explicit __apply_expr(_Fp __f) : __f_(__f) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 537 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 538 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 539 | _Tp operator()(const _Tp& __x) const |
| 540 | {return __f_(__x);} |
| 541 | }; |
| 542 | |
| 543 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 544 | struct __abs_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 545 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 546 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 547 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 548 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 549 | {return std::abs(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 550 | }; |
| 551 | |
| 552 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 553 | struct __acos_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 554 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 555 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 556 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 557 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 558 | {return std::acos(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 559 | }; |
| 560 | |
| 561 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 562 | struct __asin_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 563 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 564 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 565 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 566 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 567 | {return std::asin(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 568 | }; |
| 569 | |
| 570 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 571 | struct __atan_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 572 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 573 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 574 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 575 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 576 | {return std::atan(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 577 | }; |
| 578 | |
| 579 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 580 | struct __atan2_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 581 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 582 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 583 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 584 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 585 | {return std::atan2(__x, __y);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 586 | }; |
| 587 | |
| 588 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 589 | struct __cos_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 590 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 591 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 592 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 593 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 594 | {return std::cos(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 595 | }; |
| 596 | |
| 597 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 598 | struct __cosh_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 599 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 600 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 601 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 602 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 603 | {return std::cosh(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 604 | }; |
| 605 | |
| 606 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 607 | struct __exp_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 608 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 609 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 610 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 611 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 612 | {return std::exp(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 613 | }; |
| 614 | |
| 615 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 616 | struct __log_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 617 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 618 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 619 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 620 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 621 | {return std::log(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 622 | }; |
| 623 | |
| 624 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 625 | struct __log10_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 626 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 627 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 628 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 629 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 630 | {return std::log10(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 631 | }; |
| 632 | |
| 633 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 634 | struct __pow_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 635 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 636 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 637 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 638 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 639 | {return std::pow(__x, __y);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 640 | }; |
| 641 | |
| 642 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 643 | struct __sin_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 644 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 645 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 646 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 647 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 648 | {return std::sin(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 649 | }; |
| 650 | |
| 651 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 652 | struct __sinh_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 653 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 654 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 655 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 656 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 657 | {return std::sinh(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 658 | }; |
| 659 | |
| 660 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 661 | struct __sqrt_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 662 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 663 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 664 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 665 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 666 | {return std::sqrt(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 667 | }; |
| 668 | |
| 669 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 670 | struct __tan_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 671 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 672 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 673 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 674 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 675 | {return std::tan(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 676 | }; |
| 677 | |
| 678 | template <class _Tp> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 679 | struct __tanh_expr |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 680 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 681 | typedef _Tp __result_type; |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 682 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 683 | _Tp operator()(const _Tp& __x) const |
Nikolas Klauser | 0ada919 | 2022-08-13 22:33:12 +0200 | [diff] [blame] | 684 | {return std::tanh(__x);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 685 | }; |
| 686 | |
| 687 | template <class _ValExpr> |
| 688 | class __slice_expr |
| 689 | { |
Nikolas Klauser | c9e524e | 2022-09-06 00:33:34 +0200 | [diff] [blame] | 690 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 691 | public: |
| 692 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 693 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 694 | |
| 695 | private: |
| 696 | _ValExpr __expr_; |
| 697 | size_t __start_; |
| 698 | size_t __size_; |
| 699 | size_t __stride_; |
| 700 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 701 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 702 | __slice_expr(const slice& __sl, const _RmExpr& __e) |
| 703 | : __expr_(__e), |
| 704 | __start_(__sl.start()), |
| 705 | __size_(__sl.size()), |
| 706 | __stride_(__sl.stride()) |
| 707 | {} |
| 708 | public: |
| 709 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 710 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 711 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 712 | {return __expr_[__start_ + __i * __stride_];} |
| 713 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 714 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 715 | size_t size() const {return __size_;} |
| 716 | |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 717 | template <class> friend class __val_expr; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 718 | template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 719 | }; |
| 720 | |
| 721 | template <class _ValExpr> |
| 722 | class __mask_expr; |
| 723 | |
| 724 | template <class _ValExpr> |
| 725 | class __indirect_expr; |
| 726 | |
| 727 | template <class _ValExpr> |
| 728 | class __shift_expr |
| 729 | { |
Nikolas Klauser | c9e524e | 2022-09-06 00:33:34 +0200 | [diff] [blame] | 730 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 731 | public: |
| 732 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 733 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 734 | |
| 735 | private: |
| 736 | _ValExpr __expr_; |
| 737 | size_t __size_; |
| 738 | ptrdiff_t __ul_; |
| 739 | ptrdiff_t __sn_; |
| 740 | ptrdiff_t __n_; |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 741 | static const ptrdiff_t _Np = static_cast<ptrdiff_t>( |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 742 | sizeof(ptrdiff_t) * __CHAR_BIT__ - 1); |
| 743 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 744 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 745 | __shift_expr(int __n, const _RmExpr& __e) |
| 746 | : __expr_(__e), |
| 747 | __size_(__e.size()), |
| 748 | __n_(__n) |
| 749 | { |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 750 | ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np); |
| 751 | __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 752 | __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n); |
| 753 | } |
| 754 | public: |
| 755 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 756 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 757 | __result_type operator[](size_t __j) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 758 | { |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 759 | ptrdiff_t __i = static_cast<ptrdiff_t>(__j); |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 760 | ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 761 | return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m); |
| 762 | } |
| 763 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 764 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 765 | size_t size() const {return __size_;} |
| 766 | |
| 767 | template <class> friend class __val_expr; |
| 768 | }; |
| 769 | |
| 770 | template <class _ValExpr> |
| 771 | class __cshift_expr |
| 772 | { |
Nikolas Klauser | c9e524e | 2022-09-06 00:33:34 +0200 | [diff] [blame] | 773 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 774 | public: |
| 775 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 776 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 777 | |
| 778 | private: |
| 779 | _ValExpr __expr_; |
| 780 | size_t __size_; |
| 781 | size_t __m_; |
| 782 | size_t __o1_; |
| 783 | size_t __o2_; |
| 784 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 785 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 786 | __cshift_expr(int __n, const _RmExpr& __e) |
| 787 | : __expr_(__e), |
| 788 | __size_(__e.size()) |
| 789 | { |
| 790 | __n %= static_cast<int>(__size_); |
| 791 | if (__n >= 0) |
| 792 | { |
| 793 | __m_ = __size_ - __n; |
| 794 | __o1_ = __n; |
| 795 | __o2_ = __n - __size_; |
| 796 | } |
| 797 | else |
| 798 | { |
| 799 | __m_ = -__n; |
| 800 | __o1_ = __n + __size_; |
| 801 | __o2_ = __n; |
| 802 | } |
| 803 | } |
| 804 | public: |
| 805 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 806 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 807 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 808 | { |
| 809 | if (__i < __m_) |
| 810 | return __expr_[__i + __o1_]; |
| 811 | return __expr_[__i + __o2_]; |
| 812 | } |
| 813 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 814 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 815 | size_t size() const {return __size_;} |
| 816 | |
| 817 | template <class> friend class __val_expr; |
| 818 | }; |
| 819 | |
| 820 | template<class _ValExpr> |
| 821 | class __val_expr; |
| 822 | |
| 823 | template<class _ValExpr> |
| 824 | struct __is_val_expr : false_type {}; |
| 825 | |
| 826 | template<class _ValExpr> |
| 827 | struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; |
| 828 | |
| 829 | template<class _Tp> |
| 830 | struct __is_val_expr<valarray<_Tp> > : true_type {}; |
| 831 | |
| 832 | template<class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 833 | class _LIBCPP_TEMPLATE_VIS valarray |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 834 | { |
| 835 | public: |
| 836 | typedef _Tp value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 837 | typedef _Tp __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 838 | |
| 839 | private: |
| 840 | value_type* __begin_; |
| 841 | value_type* __end_; |
| 842 | |
| 843 | public: |
| 844 | // construct/destroy: |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 845 | _LIBCPP_INLINE_VISIBILITY |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 846 | valarray() : __begin_(nullptr), __end_(nullptr) {} |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 847 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Eric Fiselier | e529a80 | 2016-09-16 00:13:55 +0000 | [diff] [blame] | 848 | explicit valarray(size_t __n); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 849 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 850 | valarray(const value_type& __x, size_t __n); |
| 851 | valarray(const value_type* __p, size_t __n); |
| 852 | valarray(const valarray& __v); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 853 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 854 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 855 | valarray(valarray&& __v) _NOEXCEPT; |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 856 | valarray(initializer_list<value_type> __il); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 857 | #endif // _LIBCPP_CXX03_LANG |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 858 | valarray(const slice_array<value_type>& __sa); |
| 859 | valarray(const gslice_array<value_type>& __ga); |
| 860 | valarray(const mask_array<value_type>& __ma); |
| 861 | valarray(const indirect_array<value_type>& __ia); |
Louis Dionne | b4d05d7 | 2018-10-16 19:26:23 +0000 | [diff] [blame] | 862 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 863 | ~valarray(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 864 | |
| 865 | // assignment: |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 866 | valarray& operator=(const valarray& __v); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 867 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 868 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 869 | valarray& operator=(valarray&& __v) _NOEXCEPT; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 870 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 871 | valarray& operator=(initializer_list<value_type>); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 872 | #endif // _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 873 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 874 | valarray& operator=(const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 875 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 876 | valarray& operator=(const slice_array<value_type>& __sa); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 877 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 878 | valarray& operator=(const gslice_array<value_type>& __ga); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 879 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 880 | valarray& operator=(const mask_array<value_type>& __ma); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 881 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 882 | valarray& operator=(const indirect_array<value_type>& __ia); |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 883 | template <class _ValExpr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 884 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 885 | valarray& operator=(const __val_expr<_ValExpr>& __v); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 886 | |
| 887 | // element access: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 888 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 889 | const value_type& operator[](size_t __i) const {return __begin_[__i];} |
| 890 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 891 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 892 | value_type& operator[](size_t __i) {return __begin_[__i];} |
| 893 | |
| 894 | // subset operations: |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 895 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 896 | __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 897 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 898 | slice_array<value_type> operator[](slice __s); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 899 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 900 | __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 901 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 902 | gslice_array<value_type> operator[](const gslice& __gs); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 903 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 904 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 905 | __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 906 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 907 | gslice_array<value_type> operator[](gslice&& __gs); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 908 | #endif // _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 909 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 910 | __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 911 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 912 | mask_array<value_type> operator[](const valarray<bool>& __vb); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 913 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 914 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 915 | __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 916 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 917 | mask_array<value_type> operator[](valarray<bool>&& __vb); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 918 | #endif // _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 919 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 920 | __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 921 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 922 | indirect_array<value_type> operator[](const valarray<size_t>& __vs); |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 923 | #ifndef _LIBCPP_CXX03_LANG |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 924 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 925 | __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 926 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 927 | indirect_array<value_type> operator[](valarray<size_t>&& __vs); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 928 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 929 | |
| 930 | // unary operators: |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 931 | _LIBCPP_INLINE_VISIBILITY |
| 932 | __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const; |
| 933 | _LIBCPP_INLINE_VISIBILITY |
| 934 | __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const; |
| 935 | _LIBCPP_INLINE_VISIBILITY |
| 936 | __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const; |
| 937 | _LIBCPP_INLINE_VISIBILITY |
| 938 | __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 939 | |
| 940 | // computed assignment: |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 941 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 942 | valarray& operator*= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 943 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 944 | valarray& operator/= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 945 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 946 | valarray& operator%= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 947 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 948 | valarray& operator+= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 949 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 950 | valarray& operator-= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 951 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 952 | valarray& operator^= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 953 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 954 | valarray& operator&= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 955 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 956 | valarray& operator|= (const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 957 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 958 | valarray& operator<<=(const value_type& __x); |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 959 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 960 | valarray& operator>>=(const value_type& __x); |
| 961 | |
| 962 | template <class _Expr> |
| 963 | typename enable_if |
| 964 | < |
| 965 | __is_val_expr<_Expr>::value, |
| 966 | valarray& |
| 967 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 968 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 969 | operator*= (const _Expr& __v); |
| 970 | |
| 971 | template <class _Expr> |
| 972 | typename enable_if |
| 973 | < |
| 974 | __is_val_expr<_Expr>::value, |
| 975 | valarray& |
| 976 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 977 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 978 | operator/= (const _Expr& __v); |
| 979 | |
| 980 | template <class _Expr> |
| 981 | typename enable_if |
| 982 | < |
| 983 | __is_val_expr<_Expr>::value, |
| 984 | valarray& |
| 985 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 986 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 987 | operator%= (const _Expr& __v); |
| 988 | |
| 989 | template <class _Expr> |
| 990 | typename enable_if |
| 991 | < |
| 992 | __is_val_expr<_Expr>::value, |
| 993 | valarray& |
| 994 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 995 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 996 | operator+= (const _Expr& __v); |
| 997 | |
| 998 | template <class _Expr> |
| 999 | typename enable_if |
| 1000 | < |
| 1001 | __is_val_expr<_Expr>::value, |
| 1002 | valarray& |
| 1003 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1004 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1005 | operator-= (const _Expr& __v); |
| 1006 | |
| 1007 | template <class _Expr> |
| 1008 | typename enable_if |
| 1009 | < |
| 1010 | __is_val_expr<_Expr>::value, |
| 1011 | valarray& |
| 1012 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1013 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1014 | operator^= (const _Expr& __v); |
| 1015 | |
| 1016 | template <class _Expr> |
| 1017 | typename enable_if |
| 1018 | < |
| 1019 | __is_val_expr<_Expr>::value, |
| 1020 | valarray& |
| 1021 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1022 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1023 | operator|= (const _Expr& __v); |
| 1024 | |
| 1025 | template <class _Expr> |
| 1026 | typename enable_if |
| 1027 | < |
| 1028 | __is_val_expr<_Expr>::value, |
| 1029 | valarray& |
| 1030 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1031 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1032 | operator&= (const _Expr& __v); |
| 1033 | |
| 1034 | template <class _Expr> |
| 1035 | typename enable_if |
| 1036 | < |
| 1037 | __is_val_expr<_Expr>::value, |
| 1038 | valarray& |
| 1039 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1040 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1041 | operator<<= (const _Expr& __v); |
| 1042 | |
| 1043 | template <class _Expr> |
| 1044 | typename enable_if |
| 1045 | < |
| 1046 | __is_val_expr<_Expr>::value, |
| 1047 | valarray& |
| 1048 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1049 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1050 | operator>>= (const _Expr& __v); |
| 1051 | |
| 1052 | // member functions: |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1053 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 1054 | void swap(valarray& __v) _NOEXCEPT; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1055 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1056 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 1057 | size_t size() const {return static_cast<size_t>(__end_ - __begin_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1058 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1059 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1060 | value_type sum() const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1061 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1062 | value_type min() const; |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1063 | _LIBCPP_INLINE_VISIBILITY |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1064 | value_type max() const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1065 | |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1066 | valarray shift (int __i) const; |
| 1067 | valarray cshift(int __i) const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1068 | valarray apply(value_type __f(value_type)) const; |
| 1069 | valarray apply(value_type __f(const value_type&)) const; |
| 1070 | void resize(size_t __n, value_type __x = value_type()); |
| 1071 | |
| 1072 | private: |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1073 | template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; |
| 1074 | template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array; |
| 1075 | template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array; |
| 1076 | template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1077 | template <class> friend class __mask_expr; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1078 | template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1079 | template <class> friend class __indirect_expr; |
| 1080 | template <class> friend class __val_expr; |
| 1081 | |
| 1082 | template <class _Up> |
| 1083 | friend |
| 1084 | _Up* |
| 1085 | begin(valarray<_Up>& __v); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1086 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1087 | template <class _Up> |
| 1088 | friend |
| 1089 | const _Up* |
| 1090 | begin(const valarray<_Up>& __v); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1091 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1092 | template <class _Up> |
| 1093 | friend |
| 1094 | _Up* |
| 1095 | end(valarray<_Up>& __v); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1096 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1097 | template <class _Up> |
| 1098 | friend |
| 1099 | const _Up* |
| 1100 | end(const valarray<_Up>& __v); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 1101 | |
Eric Fiselier | a119c32 | 2018-10-25 17:43:26 +0000 | [diff] [blame] | 1102 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 1103 | void __clear(size_t __capacity); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 1104 | valarray& __assign_range(const value_type* __f, const value_type* __l); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1105 | }; |
| 1106 | |
Konstantin Varlamov | ebb3119 | 2021-10-28 00:36:19 -0700 | [diff] [blame] | 1107 | #if _LIBCPP_STD_VER > 14 |
| 1108 | template<class _Tp, size_t _Size> |
| 1109 | valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>; |
| 1110 | #endif |
| 1111 | |
Louis Dionne | dc496ec | 2021-06-08 17:25:08 -0400 | [diff] [blame] | 1112 | extern template _LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t); |
Howard Hinnant | a37d3cf | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 1113 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1114 | template <class _Op, class _Tp> |
| 1115 | struct _UnaryOp<_Op, valarray<_Tp> > |
| 1116 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1117 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1118 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1119 | |
| 1120 | _Op __op_; |
| 1121 | const valarray<_Tp>& __a0_; |
| 1122 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1123 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1124 | _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {} |
| 1125 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1126 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1127 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1128 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1129 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1130 | size_t size() const {return __a0_.size();} |
| 1131 | }; |
| 1132 | |
| 1133 | template <class _Op, class _Tp, class _A1> |
| 1134 | struct _BinaryOp<_Op, valarray<_Tp>, _A1> |
| 1135 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1136 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1137 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1138 | |
| 1139 | _Op __op_; |
| 1140 | const valarray<_Tp>& __a0_; |
| 1141 | _A1 __a1_; |
| 1142 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1143 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1144 | _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1) |
| 1145 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 1146 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1147 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1148 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1149 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1150 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1151 | size_t size() const {return __a0_.size();} |
| 1152 | }; |
| 1153 | |
| 1154 | template <class _Op, class _A0, class _Tp> |
| 1155 | struct _BinaryOp<_Op, _A0, valarray<_Tp> > |
| 1156 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1157 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1158 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1159 | |
| 1160 | _Op __op_; |
| 1161 | _A0 __a0_; |
| 1162 | const valarray<_Tp>& __a1_; |
| 1163 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1164 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1165 | _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1) |
| 1166 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 1167 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1168 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1169 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1170 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1171 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1172 | size_t size() const {return __a0_.size();} |
| 1173 | }; |
| 1174 | |
| 1175 | template <class _Op, class _Tp> |
| 1176 | struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > |
| 1177 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 1178 | typedef typename _Op::__result_type __result_type; |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1179 | typedef typename decay<__result_type>::type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1180 | |
| 1181 | _Op __op_; |
| 1182 | const valarray<_Tp>& __a0_; |
| 1183 | const valarray<_Tp>& __a1_; |
| 1184 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1185 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1186 | _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1) |
| 1187 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
| 1188 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1189 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 0b6c248 | 2021-05-31 11:33:51 -0400 | [diff] [blame] | 1190 | __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1191 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1192 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1193 | size_t size() const {return __a0_.size();} |
| 1194 | }; |
| 1195 | |
| 1196 | // slice_array |
| 1197 | |
| 1198 | template <class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1199 | class _LIBCPP_TEMPLATE_VIS slice_array |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1200 | { |
| 1201 | public: |
| 1202 | typedef _Tp value_type; |
| 1203 | |
| 1204 | private: |
| 1205 | value_type* __vp_; |
| 1206 | size_t __size_; |
| 1207 | size_t __stride_; |
| 1208 | |
| 1209 | public: |
| 1210 | template <class _Expr> |
| 1211 | typename enable_if |
| 1212 | < |
| 1213 | __is_val_expr<_Expr>::value, |
| 1214 | void |
| 1215 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1216 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1217 | operator=(const _Expr& __v) const; |
| 1218 | |
| 1219 | template <class _Expr> |
| 1220 | typename enable_if |
| 1221 | < |
| 1222 | __is_val_expr<_Expr>::value, |
| 1223 | void |
| 1224 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1225 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1226 | operator*=(const _Expr& __v) const; |
| 1227 | |
| 1228 | template <class _Expr> |
| 1229 | typename enable_if |
| 1230 | < |
| 1231 | __is_val_expr<_Expr>::value, |
| 1232 | void |
| 1233 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1234 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1235 | operator/=(const _Expr& __v) const; |
| 1236 | |
| 1237 | template <class _Expr> |
| 1238 | typename enable_if |
| 1239 | < |
| 1240 | __is_val_expr<_Expr>::value, |
| 1241 | void |
| 1242 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1243 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1244 | operator%=(const _Expr& __v) const; |
| 1245 | |
| 1246 | template <class _Expr> |
| 1247 | typename enable_if |
| 1248 | < |
| 1249 | __is_val_expr<_Expr>::value, |
| 1250 | void |
| 1251 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1252 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1253 | operator+=(const _Expr& __v) const; |
| 1254 | |
| 1255 | template <class _Expr> |
| 1256 | typename enable_if |
| 1257 | < |
| 1258 | __is_val_expr<_Expr>::value, |
| 1259 | void |
| 1260 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1261 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1262 | operator-=(const _Expr& __v) const; |
| 1263 | |
| 1264 | template <class _Expr> |
| 1265 | typename enable_if |
| 1266 | < |
| 1267 | __is_val_expr<_Expr>::value, |
| 1268 | void |
| 1269 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1270 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1271 | operator^=(const _Expr& __v) const; |
| 1272 | |
| 1273 | template <class _Expr> |
| 1274 | typename enable_if |
| 1275 | < |
| 1276 | __is_val_expr<_Expr>::value, |
| 1277 | void |
| 1278 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1279 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1280 | operator&=(const _Expr& __v) const; |
| 1281 | |
| 1282 | template <class _Expr> |
| 1283 | typename enable_if |
| 1284 | < |
| 1285 | __is_val_expr<_Expr>::value, |
| 1286 | void |
| 1287 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1288 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1289 | operator|=(const _Expr& __v) const; |
| 1290 | |
| 1291 | template <class _Expr> |
| 1292 | typename enable_if |
| 1293 | < |
| 1294 | __is_val_expr<_Expr>::value, |
| 1295 | void |
| 1296 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1297 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1298 | operator<<=(const _Expr& __v) const; |
| 1299 | |
| 1300 | template <class _Expr> |
| 1301 | typename enable_if |
| 1302 | < |
| 1303 | __is_val_expr<_Expr>::value, |
| 1304 | void |
| 1305 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1306 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1307 | operator>>=(const _Expr& __v) const; |
| 1308 | |
Eric Fiselier | b9f37ca | 2019-12-12 20:48:11 -0500 | [diff] [blame] | 1309 | slice_array(slice_array const&) = default; |
| 1310 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1311 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1312 | const slice_array& operator=(const slice_array& __sa) const; |
| 1313 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1314 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1315 | void operator=(const value_type& __x) const; |
| 1316 | |
zoecarver | 79fa750 | 2020-12-02 10:49:20 -0800 | [diff] [blame] | 1317 | _LIBCPP_INLINE_VISIBILITY |
| 1318 | void operator=(const valarray<value_type>& __va) const; |
| 1319 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1320 | private: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1321 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1322 | slice_array(const slice& __sl, const valarray<value_type>& __v) |
| 1323 | : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), |
| 1324 | __size_(__sl.size()), |
| 1325 | __stride_(__sl.stride()) |
| 1326 | {} |
| 1327 | |
| 1328 | template <class> friend class valarray; |
| 1329 | template <class> friend class sliceExpr; |
| 1330 | }; |
| 1331 | |
| 1332 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1333 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1334 | const slice_array<_Tp>& |
| 1335 | slice_array<_Tp>::operator=(const slice_array& __sa) const |
| 1336 | { |
| 1337 | value_type* __t = __vp_; |
| 1338 | const value_type* __s = __sa.__vp_; |
| 1339 | for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_) |
| 1340 | *__t = *__s; |
Eric Fiselier | 3b80ce9 | 2014-08-12 00:06:58 +0000 | [diff] [blame] | 1341 | return *this; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | template <class _Tp> |
| 1345 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1346 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1347 | typename enable_if |
| 1348 | < |
| 1349 | __is_val_expr<_Expr>::value, |
| 1350 | void |
| 1351 | >::type |
| 1352 | slice_array<_Tp>::operator=(const _Expr& __v) const |
| 1353 | { |
| 1354 | value_type* __t = __vp_; |
| 1355 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1356 | *__t = __v[__i]; |
| 1357 | } |
| 1358 | |
| 1359 | template <class _Tp> |
zoecarver | 79fa750 | 2020-12-02 10:49:20 -0800 | [diff] [blame] | 1360 | inline void |
| 1361 | slice_array<_Tp>::operator=(const valarray<value_type>& __va) const |
| 1362 | { |
| 1363 | value_type* __t = __vp_; |
| 1364 | for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_) |
| 1365 | *__t = __va[__i]; |
| 1366 | } |
| 1367 | |
| 1368 | template <class _Tp> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1369 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1370 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1371 | typename enable_if |
| 1372 | < |
| 1373 | __is_val_expr<_Expr>::value, |
| 1374 | void |
| 1375 | >::type |
| 1376 | slice_array<_Tp>::operator*=(const _Expr& __v) const |
| 1377 | { |
| 1378 | value_type* __t = __vp_; |
| 1379 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1380 | *__t *= __v[__i]; |
| 1381 | } |
| 1382 | |
| 1383 | template <class _Tp> |
| 1384 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1385 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1386 | typename enable_if |
| 1387 | < |
| 1388 | __is_val_expr<_Expr>::value, |
| 1389 | void |
| 1390 | >::type |
| 1391 | slice_array<_Tp>::operator/=(const _Expr& __v) const |
| 1392 | { |
| 1393 | value_type* __t = __vp_; |
| 1394 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1395 | *__t /= __v[__i]; |
| 1396 | } |
| 1397 | |
| 1398 | template <class _Tp> |
| 1399 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1400 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1401 | typename enable_if |
| 1402 | < |
| 1403 | __is_val_expr<_Expr>::value, |
| 1404 | void |
| 1405 | >::type |
| 1406 | slice_array<_Tp>::operator%=(const _Expr& __v) const |
| 1407 | { |
| 1408 | value_type* __t = __vp_; |
| 1409 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1410 | *__t %= __v[__i]; |
| 1411 | } |
| 1412 | |
| 1413 | template <class _Tp> |
| 1414 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1415 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1416 | typename enable_if |
| 1417 | < |
| 1418 | __is_val_expr<_Expr>::value, |
| 1419 | void |
| 1420 | >::type |
| 1421 | slice_array<_Tp>::operator+=(const _Expr& __v) const |
| 1422 | { |
| 1423 | value_type* __t = __vp_; |
| 1424 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1425 | *__t += __v[__i]; |
| 1426 | } |
| 1427 | |
| 1428 | template <class _Tp> |
| 1429 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1430 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1431 | typename enable_if |
| 1432 | < |
| 1433 | __is_val_expr<_Expr>::value, |
| 1434 | void |
| 1435 | >::type |
| 1436 | slice_array<_Tp>::operator-=(const _Expr& __v) const |
| 1437 | { |
| 1438 | value_type* __t = __vp_; |
| 1439 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1440 | *__t -= __v[__i]; |
| 1441 | } |
| 1442 | |
| 1443 | template <class _Tp> |
| 1444 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1445 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1446 | typename enable_if |
| 1447 | < |
| 1448 | __is_val_expr<_Expr>::value, |
| 1449 | void |
| 1450 | >::type |
| 1451 | slice_array<_Tp>::operator^=(const _Expr& __v) const |
| 1452 | { |
| 1453 | value_type* __t = __vp_; |
| 1454 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1455 | *__t ^= __v[__i]; |
| 1456 | } |
| 1457 | |
| 1458 | template <class _Tp> |
| 1459 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1460 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1461 | typename enable_if |
| 1462 | < |
| 1463 | __is_val_expr<_Expr>::value, |
| 1464 | void |
| 1465 | >::type |
| 1466 | slice_array<_Tp>::operator&=(const _Expr& __v) const |
| 1467 | { |
| 1468 | value_type* __t = __vp_; |
| 1469 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1470 | *__t &= __v[__i]; |
| 1471 | } |
| 1472 | |
| 1473 | template <class _Tp> |
| 1474 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1475 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1476 | typename enable_if |
| 1477 | < |
| 1478 | __is_val_expr<_Expr>::value, |
| 1479 | void |
| 1480 | >::type |
| 1481 | slice_array<_Tp>::operator|=(const _Expr& __v) const |
| 1482 | { |
| 1483 | value_type* __t = __vp_; |
| 1484 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1485 | *__t |= __v[__i]; |
| 1486 | } |
| 1487 | |
| 1488 | template <class _Tp> |
| 1489 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1490 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1491 | typename enable_if |
| 1492 | < |
| 1493 | __is_val_expr<_Expr>::value, |
| 1494 | void |
| 1495 | >::type |
| 1496 | slice_array<_Tp>::operator<<=(const _Expr& __v) const |
| 1497 | { |
| 1498 | value_type* __t = __vp_; |
| 1499 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1500 | *__t <<= __v[__i]; |
| 1501 | } |
| 1502 | |
| 1503 | template <class _Tp> |
| 1504 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1505 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1506 | typename enable_if |
| 1507 | < |
| 1508 | __is_val_expr<_Expr>::value, |
| 1509 | void |
| 1510 | >::type |
| 1511 | slice_array<_Tp>::operator>>=(const _Expr& __v) const |
| 1512 | { |
| 1513 | value_type* __t = __vp_; |
| 1514 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
| 1515 | *__t >>= __v[__i]; |
| 1516 | } |
| 1517 | |
| 1518 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1519 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1520 | void |
| 1521 | slice_array<_Tp>::operator=(const value_type& __x) const |
| 1522 | { |
| 1523 | value_type* __t = __vp_; |
| 1524 | for (size_t __n = __size_; __n; --__n, __t += __stride_) |
| 1525 | *__t = __x; |
| 1526 | } |
| 1527 | |
| 1528 | // gslice |
| 1529 | |
Howard Hinnant | 8331b76 | 2013-03-06 23:30:19 +0000 | [diff] [blame] | 1530 | class _LIBCPP_TYPE_VIS gslice |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1531 | { |
| 1532 | valarray<size_t> __size_; |
| 1533 | valarray<size_t> __stride_; |
| 1534 | valarray<size_t> __1d_; |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1535 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1536 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1537 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1538 | gslice() {} |
Douglas Gregor | 6890232 | 2012-05-19 07:14:17 +0000 | [diff] [blame] | 1539 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1540 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1541 | gslice(size_t __start, const valarray<size_t>& __size, |
| 1542 | const valarray<size_t>& __stride) |
| 1543 | : __size_(__size), |
| 1544 | __stride_(__stride) |
| 1545 | {__init(__start);} |
| 1546 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 1547 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1548 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1549 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1550 | gslice(size_t __start, const valarray<size_t>& __size, |
| 1551 | valarray<size_t>&& __stride) |
| 1552 | : __size_(__size), |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 1553 | __stride_(std::move(__stride)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1554 | {__init(__start);} |
| 1555 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1556 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1557 | gslice(size_t __start, valarray<size_t>&& __size, |
| 1558 | const valarray<size_t>& __stride) |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 1559 | : __size_(std::move(__size)), |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1560 | __stride_(__stride) |
| 1561 | {__init(__start);} |
| 1562 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1563 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1564 | gslice(size_t __start, valarray<size_t>&& __size, |
| 1565 | valarray<size_t>&& __stride) |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 1566 | : __size_(std::move(__size)), |
| 1567 | __stride_(std::move(__stride)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1568 | {__init(__start);} |
| 1569 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1570 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1571 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1572 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1573 | size_t start() const {return __1d_.size() ? __1d_[0] : 0;} |
| 1574 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1575 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1576 | valarray<size_t> size() const {return __size_;} |
| 1577 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1578 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1579 | valarray<size_t> stride() const {return __stride_;} |
| 1580 | |
| 1581 | private: |
| 1582 | void __init(size_t __start); |
| 1583 | |
| 1584 | template <class> friend class gslice_array; |
| 1585 | template <class> friend class valarray; |
| 1586 | template <class> friend class __val_expr; |
| 1587 | }; |
| 1588 | |
| 1589 | // gslice_array |
| 1590 | |
| 1591 | template <class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1592 | class _LIBCPP_TEMPLATE_VIS gslice_array |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1593 | { |
| 1594 | public: |
| 1595 | typedef _Tp value_type; |
| 1596 | |
| 1597 | private: |
| 1598 | value_type* __vp_; |
| 1599 | valarray<size_t> __1d_; |
| 1600 | |
| 1601 | public: |
| 1602 | template <class _Expr> |
| 1603 | typename enable_if |
| 1604 | < |
| 1605 | __is_val_expr<_Expr>::value, |
| 1606 | void |
| 1607 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1608 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1609 | operator=(const _Expr& __v) const; |
| 1610 | |
| 1611 | template <class _Expr> |
| 1612 | typename enable_if |
| 1613 | < |
| 1614 | __is_val_expr<_Expr>::value, |
| 1615 | void |
| 1616 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1617 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1618 | operator*=(const _Expr& __v) const; |
| 1619 | |
| 1620 | template <class _Expr> |
| 1621 | typename enable_if |
| 1622 | < |
| 1623 | __is_val_expr<_Expr>::value, |
| 1624 | void |
| 1625 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1626 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1627 | operator/=(const _Expr& __v) const; |
| 1628 | |
| 1629 | template <class _Expr> |
| 1630 | typename enable_if |
| 1631 | < |
| 1632 | __is_val_expr<_Expr>::value, |
| 1633 | void |
| 1634 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1635 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1636 | operator%=(const _Expr& __v) const; |
| 1637 | |
| 1638 | template <class _Expr> |
| 1639 | typename enable_if |
| 1640 | < |
| 1641 | __is_val_expr<_Expr>::value, |
| 1642 | void |
| 1643 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1644 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1645 | operator+=(const _Expr& __v) const; |
| 1646 | |
| 1647 | template <class _Expr> |
| 1648 | typename enable_if |
| 1649 | < |
| 1650 | __is_val_expr<_Expr>::value, |
| 1651 | void |
| 1652 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1653 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1654 | operator-=(const _Expr& __v) const; |
| 1655 | |
| 1656 | template <class _Expr> |
| 1657 | typename enable_if |
| 1658 | < |
| 1659 | __is_val_expr<_Expr>::value, |
| 1660 | void |
| 1661 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1662 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1663 | operator^=(const _Expr& __v) const; |
| 1664 | |
| 1665 | template <class _Expr> |
| 1666 | typename enable_if |
| 1667 | < |
| 1668 | __is_val_expr<_Expr>::value, |
| 1669 | void |
| 1670 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1671 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1672 | operator&=(const _Expr& __v) const; |
| 1673 | |
| 1674 | template <class _Expr> |
| 1675 | typename enable_if |
| 1676 | < |
| 1677 | __is_val_expr<_Expr>::value, |
| 1678 | void |
| 1679 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1680 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1681 | operator|=(const _Expr& __v) const; |
| 1682 | |
| 1683 | template <class _Expr> |
| 1684 | typename enable_if |
| 1685 | < |
| 1686 | __is_val_expr<_Expr>::value, |
| 1687 | void |
| 1688 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1689 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1690 | operator<<=(const _Expr& __v) const; |
| 1691 | |
| 1692 | template <class _Expr> |
| 1693 | typename enable_if |
| 1694 | < |
| 1695 | __is_val_expr<_Expr>::value, |
| 1696 | void |
| 1697 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1698 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1699 | operator>>=(const _Expr& __v) const; |
| 1700 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1701 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1702 | const gslice_array& operator=(const gslice_array& __ga) const; |
| 1703 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1704 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1705 | void operator=(const value_type& __x) const; |
| 1706 | |
Eric Fiselier | b9f37ca | 2019-12-12 20:48:11 -0500 | [diff] [blame] | 1707 | gslice_array(const gslice_array&) = default; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1708 | |
| 1709 | private: |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1710 | gslice_array(const gslice& __gs, const valarray<value_type>& __v) |
| 1711 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
| 1712 | __1d_(__gs.__1d_) |
| 1713 | {} |
| 1714 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 1715 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1716 | gslice_array(gslice&& __gs, const valarray<value_type>& __v) |
| 1717 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 1718 | __1d_(std::move(__gs.__1d_)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1719 | {} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1720 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1721 | |
| 1722 | template <class> friend class valarray; |
| 1723 | }; |
| 1724 | |
| 1725 | template <class _Tp> |
| 1726 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1727 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1728 | typename enable_if |
| 1729 | < |
| 1730 | __is_val_expr<_Expr>::value, |
| 1731 | void |
| 1732 | >::type |
| 1733 | gslice_array<_Tp>::operator=(const _Expr& __v) const |
| 1734 | { |
| 1735 | typedef const size_t* _Ip; |
| 1736 | size_t __j = 0; |
| 1737 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1738 | __vp_[*__i] = __v[__j]; |
| 1739 | } |
| 1740 | |
| 1741 | template <class _Tp> |
| 1742 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1743 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1744 | typename enable_if |
| 1745 | < |
| 1746 | __is_val_expr<_Expr>::value, |
| 1747 | void |
| 1748 | >::type |
| 1749 | gslice_array<_Tp>::operator*=(const _Expr& __v) const |
| 1750 | { |
| 1751 | typedef const size_t* _Ip; |
| 1752 | size_t __j = 0; |
| 1753 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1754 | __vp_[*__i] *= __v[__j]; |
| 1755 | } |
| 1756 | |
| 1757 | template <class _Tp> |
| 1758 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1759 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1760 | typename enable_if |
| 1761 | < |
| 1762 | __is_val_expr<_Expr>::value, |
| 1763 | void |
| 1764 | >::type |
| 1765 | gslice_array<_Tp>::operator/=(const _Expr& __v) const |
| 1766 | { |
| 1767 | typedef const size_t* _Ip; |
| 1768 | size_t __j = 0; |
| 1769 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1770 | __vp_[*__i] /= __v[__j]; |
| 1771 | } |
| 1772 | |
| 1773 | template <class _Tp> |
| 1774 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1775 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1776 | typename enable_if |
| 1777 | < |
| 1778 | __is_val_expr<_Expr>::value, |
| 1779 | void |
| 1780 | >::type |
| 1781 | gslice_array<_Tp>::operator%=(const _Expr& __v) const |
| 1782 | { |
| 1783 | typedef const size_t* _Ip; |
| 1784 | size_t __j = 0; |
| 1785 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1786 | __vp_[*__i] %= __v[__j]; |
| 1787 | } |
| 1788 | |
| 1789 | template <class _Tp> |
| 1790 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1791 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1792 | typename enable_if |
| 1793 | < |
| 1794 | __is_val_expr<_Expr>::value, |
| 1795 | void |
| 1796 | >::type |
| 1797 | gslice_array<_Tp>::operator+=(const _Expr& __v) const |
| 1798 | { |
| 1799 | typedef const size_t* _Ip; |
| 1800 | size_t __j = 0; |
| 1801 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1802 | __vp_[*__i] += __v[__j]; |
| 1803 | } |
| 1804 | |
| 1805 | template <class _Tp> |
| 1806 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1807 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1808 | typename enable_if |
| 1809 | < |
| 1810 | __is_val_expr<_Expr>::value, |
| 1811 | void |
| 1812 | >::type |
| 1813 | gslice_array<_Tp>::operator-=(const _Expr& __v) const |
| 1814 | { |
| 1815 | typedef const size_t* _Ip; |
| 1816 | size_t __j = 0; |
| 1817 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1818 | __vp_[*__i] -= __v[__j]; |
| 1819 | } |
| 1820 | |
| 1821 | template <class _Tp> |
| 1822 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1823 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1824 | typename enable_if |
| 1825 | < |
| 1826 | __is_val_expr<_Expr>::value, |
| 1827 | void |
| 1828 | >::type |
| 1829 | gslice_array<_Tp>::operator^=(const _Expr& __v) const |
| 1830 | { |
| 1831 | typedef const size_t* _Ip; |
| 1832 | size_t __j = 0; |
| 1833 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1834 | __vp_[*__i] ^= __v[__j]; |
| 1835 | } |
| 1836 | |
| 1837 | template <class _Tp> |
| 1838 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1839 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1840 | typename enable_if |
| 1841 | < |
| 1842 | __is_val_expr<_Expr>::value, |
| 1843 | void |
| 1844 | >::type |
| 1845 | gslice_array<_Tp>::operator&=(const _Expr& __v) const |
| 1846 | { |
| 1847 | typedef const size_t* _Ip; |
| 1848 | size_t __j = 0; |
| 1849 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1850 | __vp_[*__i] &= __v[__j]; |
| 1851 | } |
| 1852 | |
| 1853 | template <class _Tp> |
| 1854 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1855 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1856 | typename enable_if |
| 1857 | < |
| 1858 | __is_val_expr<_Expr>::value, |
| 1859 | void |
| 1860 | >::type |
| 1861 | gslice_array<_Tp>::operator|=(const _Expr& __v) const |
| 1862 | { |
| 1863 | typedef const size_t* _Ip; |
| 1864 | size_t __j = 0; |
| 1865 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1866 | __vp_[*__i] |= __v[__j]; |
| 1867 | } |
| 1868 | |
| 1869 | template <class _Tp> |
| 1870 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1871 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1872 | typename enable_if |
| 1873 | < |
| 1874 | __is_val_expr<_Expr>::value, |
| 1875 | void |
| 1876 | >::type |
| 1877 | gslice_array<_Tp>::operator<<=(const _Expr& __v) const |
| 1878 | { |
| 1879 | typedef const size_t* _Ip; |
| 1880 | size_t __j = 0; |
| 1881 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1882 | __vp_[*__i] <<= __v[__j]; |
| 1883 | } |
| 1884 | |
| 1885 | template <class _Tp> |
| 1886 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1887 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1888 | typename enable_if |
| 1889 | < |
| 1890 | __is_val_expr<_Expr>::value, |
| 1891 | void |
| 1892 | >::type |
| 1893 | gslice_array<_Tp>::operator>>=(const _Expr& __v) const |
| 1894 | { |
| 1895 | typedef const size_t* _Ip; |
| 1896 | size_t __j = 0; |
| 1897 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
| 1898 | __vp_[*__i] >>= __v[__j]; |
| 1899 | } |
| 1900 | |
| 1901 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1902 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1903 | const gslice_array<_Tp>& |
| 1904 | gslice_array<_Tp>::operator=(const gslice_array& __ga) const |
| 1905 | { |
| 1906 | typedef const size_t* _Ip; |
| 1907 | const value_type* __s = __ga.__vp_; |
| 1908 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; |
| 1909 | __i != __e; ++__i, ++__j) |
| 1910 | __vp_[*__i] = __s[*__j]; |
| 1911 | return *this; |
| 1912 | } |
| 1913 | |
| 1914 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1915 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1916 | void |
| 1917 | gslice_array<_Tp>::operator=(const value_type& __x) const |
| 1918 | { |
| 1919 | typedef const size_t* _Ip; |
| 1920 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) |
| 1921 | __vp_[*__i] = __x; |
| 1922 | } |
| 1923 | |
| 1924 | // mask_array |
| 1925 | |
| 1926 | template <class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1927 | class _LIBCPP_TEMPLATE_VIS mask_array |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1928 | { |
| 1929 | public: |
| 1930 | typedef _Tp value_type; |
| 1931 | |
| 1932 | private: |
| 1933 | value_type* __vp_; |
| 1934 | valarray<size_t> __1d_; |
| 1935 | |
| 1936 | public: |
| 1937 | template <class _Expr> |
| 1938 | typename enable_if |
| 1939 | < |
| 1940 | __is_val_expr<_Expr>::value, |
| 1941 | void |
| 1942 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1943 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1944 | operator=(const _Expr& __v) const; |
| 1945 | |
| 1946 | template <class _Expr> |
| 1947 | typename enable_if |
| 1948 | < |
| 1949 | __is_val_expr<_Expr>::value, |
| 1950 | void |
| 1951 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1952 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1953 | operator*=(const _Expr& __v) const; |
| 1954 | |
| 1955 | template <class _Expr> |
| 1956 | typename enable_if |
| 1957 | < |
| 1958 | __is_val_expr<_Expr>::value, |
| 1959 | void |
| 1960 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1961 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1962 | operator/=(const _Expr& __v) const; |
| 1963 | |
| 1964 | template <class _Expr> |
| 1965 | typename enable_if |
| 1966 | < |
| 1967 | __is_val_expr<_Expr>::value, |
| 1968 | void |
| 1969 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1970 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1971 | operator%=(const _Expr& __v) const; |
| 1972 | |
| 1973 | template <class _Expr> |
| 1974 | typename enable_if |
| 1975 | < |
| 1976 | __is_val_expr<_Expr>::value, |
| 1977 | void |
| 1978 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1979 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1980 | operator+=(const _Expr& __v) const; |
| 1981 | |
| 1982 | template <class _Expr> |
| 1983 | typename enable_if |
| 1984 | < |
| 1985 | __is_val_expr<_Expr>::value, |
| 1986 | void |
| 1987 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1988 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1989 | operator-=(const _Expr& __v) const; |
| 1990 | |
| 1991 | template <class _Expr> |
| 1992 | typename enable_if |
| 1993 | < |
| 1994 | __is_val_expr<_Expr>::value, |
| 1995 | void |
| 1996 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 1997 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1998 | operator^=(const _Expr& __v) const; |
| 1999 | |
| 2000 | template <class _Expr> |
| 2001 | typename enable_if |
| 2002 | < |
| 2003 | __is_val_expr<_Expr>::value, |
| 2004 | void |
| 2005 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2006 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2007 | operator&=(const _Expr& __v) const; |
| 2008 | |
| 2009 | template <class _Expr> |
| 2010 | typename enable_if |
| 2011 | < |
| 2012 | __is_val_expr<_Expr>::value, |
| 2013 | void |
| 2014 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2015 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2016 | operator|=(const _Expr& __v) const; |
| 2017 | |
| 2018 | template <class _Expr> |
| 2019 | typename enable_if |
| 2020 | < |
| 2021 | __is_val_expr<_Expr>::value, |
| 2022 | void |
| 2023 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2024 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2025 | operator<<=(const _Expr& __v) const; |
| 2026 | |
| 2027 | template <class _Expr> |
| 2028 | typename enable_if |
| 2029 | < |
| 2030 | __is_val_expr<_Expr>::value, |
| 2031 | void |
| 2032 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2033 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2034 | operator>>=(const _Expr& __v) const; |
| 2035 | |
Eric Fiselier | b9f37ca | 2019-12-12 20:48:11 -0500 | [diff] [blame] | 2036 | mask_array(const mask_array&) = default; |
| 2037 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2038 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2039 | const mask_array& operator=(const mask_array& __ma) const; |
| 2040 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2041 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2042 | void operator=(const value_type& __x) const; |
| 2043 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2044 | private: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2045 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2046 | mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v) |
| 2047 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 2048 | __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2049 | { |
| 2050 | size_t __j = 0; |
| 2051 | for (size_t __i = 0; __i < __vb.size(); ++__i) |
| 2052 | if (__vb[__i]) |
| 2053 | __1d_[__j++] = __i; |
| 2054 | } |
| 2055 | |
| 2056 | template <class> friend class valarray; |
| 2057 | }; |
| 2058 | |
| 2059 | template <class _Tp> |
| 2060 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2061 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2062 | typename enable_if |
| 2063 | < |
| 2064 | __is_val_expr<_Expr>::value, |
| 2065 | void |
| 2066 | >::type |
| 2067 | mask_array<_Tp>::operator=(const _Expr& __v) const |
| 2068 | { |
| 2069 | size_t __n = __1d_.size(); |
| 2070 | for (size_t __i = 0; __i < __n; ++__i) |
| 2071 | __vp_[__1d_[__i]] = __v[__i]; |
| 2072 | } |
| 2073 | |
| 2074 | template <class _Tp> |
| 2075 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2076 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2077 | typename enable_if |
| 2078 | < |
| 2079 | __is_val_expr<_Expr>::value, |
| 2080 | void |
| 2081 | >::type |
| 2082 | mask_array<_Tp>::operator*=(const _Expr& __v) const |
| 2083 | { |
| 2084 | size_t __n = __1d_.size(); |
| 2085 | for (size_t __i = 0; __i < __n; ++__i) |
| 2086 | __vp_[__1d_[__i]] *= __v[__i]; |
| 2087 | } |
| 2088 | |
| 2089 | template <class _Tp> |
| 2090 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2091 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2092 | typename enable_if |
| 2093 | < |
| 2094 | __is_val_expr<_Expr>::value, |
| 2095 | void |
| 2096 | >::type |
| 2097 | mask_array<_Tp>::operator/=(const _Expr& __v) const |
| 2098 | { |
| 2099 | size_t __n = __1d_.size(); |
| 2100 | for (size_t __i = 0; __i < __n; ++__i) |
| 2101 | __vp_[__1d_[__i]] /= __v[__i]; |
| 2102 | } |
| 2103 | |
| 2104 | template <class _Tp> |
| 2105 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2106 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2107 | typename enable_if |
| 2108 | < |
| 2109 | __is_val_expr<_Expr>::value, |
| 2110 | void |
| 2111 | >::type |
| 2112 | mask_array<_Tp>::operator%=(const _Expr& __v) const |
| 2113 | { |
| 2114 | size_t __n = __1d_.size(); |
| 2115 | for (size_t __i = 0; __i < __n; ++__i) |
| 2116 | __vp_[__1d_[__i]] %= __v[__i]; |
| 2117 | } |
| 2118 | |
| 2119 | template <class _Tp> |
| 2120 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2121 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2122 | typename enable_if |
| 2123 | < |
| 2124 | __is_val_expr<_Expr>::value, |
| 2125 | void |
| 2126 | >::type |
| 2127 | mask_array<_Tp>::operator+=(const _Expr& __v) const |
| 2128 | { |
| 2129 | size_t __n = __1d_.size(); |
| 2130 | for (size_t __i = 0; __i < __n; ++__i) |
| 2131 | __vp_[__1d_[__i]] += __v[__i]; |
| 2132 | } |
| 2133 | |
| 2134 | template <class _Tp> |
| 2135 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2136 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2137 | typename enable_if |
| 2138 | < |
| 2139 | __is_val_expr<_Expr>::value, |
| 2140 | void |
| 2141 | >::type |
| 2142 | mask_array<_Tp>::operator-=(const _Expr& __v) const |
| 2143 | { |
| 2144 | size_t __n = __1d_.size(); |
| 2145 | for (size_t __i = 0; __i < __n; ++__i) |
| 2146 | __vp_[__1d_[__i]] -= __v[__i]; |
| 2147 | } |
| 2148 | |
| 2149 | template <class _Tp> |
| 2150 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2151 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2152 | typename enable_if |
| 2153 | < |
| 2154 | __is_val_expr<_Expr>::value, |
| 2155 | void |
| 2156 | >::type |
| 2157 | mask_array<_Tp>::operator^=(const _Expr& __v) const |
| 2158 | { |
| 2159 | size_t __n = __1d_.size(); |
| 2160 | for (size_t __i = 0; __i < __n; ++__i) |
| 2161 | __vp_[__1d_[__i]] ^= __v[__i]; |
| 2162 | } |
| 2163 | |
| 2164 | template <class _Tp> |
| 2165 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2166 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2167 | typename enable_if |
| 2168 | < |
| 2169 | __is_val_expr<_Expr>::value, |
| 2170 | void |
| 2171 | >::type |
| 2172 | mask_array<_Tp>::operator&=(const _Expr& __v) const |
| 2173 | { |
| 2174 | size_t __n = __1d_.size(); |
| 2175 | for (size_t __i = 0; __i < __n; ++__i) |
| 2176 | __vp_[__1d_[__i]] &= __v[__i]; |
| 2177 | } |
| 2178 | |
| 2179 | template <class _Tp> |
| 2180 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2181 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2182 | typename enable_if |
| 2183 | < |
| 2184 | __is_val_expr<_Expr>::value, |
| 2185 | void |
| 2186 | >::type |
| 2187 | mask_array<_Tp>::operator|=(const _Expr& __v) const |
| 2188 | { |
| 2189 | size_t __n = __1d_.size(); |
| 2190 | for (size_t __i = 0; __i < __n; ++__i) |
| 2191 | __vp_[__1d_[__i]] |= __v[__i]; |
| 2192 | } |
| 2193 | |
| 2194 | template <class _Tp> |
| 2195 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2196 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2197 | typename enable_if |
| 2198 | < |
| 2199 | __is_val_expr<_Expr>::value, |
| 2200 | void |
| 2201 | >::type |
| 2202 | mask_array<_Tp>::operator<<=(const _Expr& __v) const |
| 2203 | { |
| 2204 | size_t __n = __1d_.size(); |
| 2205 | for (size_t __i = 0; __i < __n; ++__i) |
| 2206 | __vp_[__1d_[__i]] <<= __v[__i]; |
| 2207 | } |
| 2208 | |
| 2209 | template <class _Tp> |
| 2210 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2211 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2212 | typename enable_if |
| 2213 | < |
| 2214 | __is_val_expr<_Expr>::value, |
| 2215 | void |
| 2216 | >::type |
| 2217 | mask_array<_Tp>::operator>>=(const _Expr& __v) const |
| 2218 | { |
| 2219 | size_t __n = __1d_.size(); |
| 2220 | for (size_t __i = 0; __i < __n; ++__i) |
| 2221 | __vp_[__1d_[__i]] >>= __v[__i]; |
| 2222 | } |
| 2223 | |
| 2224 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2225 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2226 | const mask_array<_Tp>& |
| 2227 | mask_array<_Tp>::operator=(const mask_array& __ma) const |
| 2228 | { |
| 2229 | size_t __n = __1d_.size(); |
| 2230 | for (size_t __i = 0; __i < __n; ++__i) |
| 2231 | __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]]; |
Eric Fiselier | 3b80ce9 | 2014-08-12 00:06:58 +0000 | [diff] [blame] | 2232 | return *this; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2233 | } |
| 2234 | |
| 2235 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2236 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2237 | void |
| 2238 | mask_array<_Tp>::operator=(const value_type& __x) const |
| 2239 | { |
| 2240 | size_t __n = __1d_.size(); |
| 2241 | for (size_t __i = 0; __i < __n; ++__i) |
| 2242 | __vp_[__1d_[__i]] = __x; |
| 2243 | } |
| 2244 | |
| 2245 | template <class _ValExpr> |
| 2246 | class __mask_expr |
| 2247 | { |
Nikolas Klauser | c9e524e | 2022-09-06 00:33:34 +0200 | [diff] [blame] | 2248 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2249 | public: |
| 2250 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2251 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2252 | |
| 2253 | private: |
| 2254 | _ValExpr __expr_; |
| 2255 | valarray<size_t> __1d_; |
| 2256 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2257 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2258 | __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e) |
| 2259 | : __expr_(__e), |
Howard Hinnant | 28b2488 | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 2260 | __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2261 | { |
| 2262 | size_t __j = 0; |
| 2263 | for (size_t __i = 0; __i < __vb.size(); ++__i) |
| 2264 | if (__vb[__i]) |
| 2265 | __1d_[__j++] = __i; |
| 2266 | } |
| 2267 | |
| 2268 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2269 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2270 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2271 | {return __expr_[__1d_[__i]];} |
| 2272 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2273 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2274 | size_t size() const {return __1d_.size();} |
| 2275 | |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2276 | template <class> friend class __val_expr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2277 | template <class> friend class valarray; |
| 2278 | }; |
| 2279 | |
| 2280 | // indirect_array |
| 2281 | |
| 2282 | template <class _Tp> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 2283 | class _LIBCPP_TEMPLATE_VIS indirect_array |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2284 | { |
| 2285 | public: |
| 2286 | typedef _Tp value_type; |
| 2287 | |
| 2288 | private: |
| 2289 | value_type* __vp_; |
| 2290 | valarray<size_t> __1d_; |
| 2291 | |
| 2292 | public: |
| 2293 | template <class _Expr> |
| 2294 | typename enable_if |
| 2295 | < |
| 2296 | __is_val_expr<_Expr>::value, |
| 2297 | void |
| 2298 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2299 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2300 | operator=(const _Expr& __v) const; |
| 2301 | |
| 2302 | template <class _Expr> |
| 2303 | typename enable_if |
| 2304 | < |
| 2305 | __is_val_expr<_Expr>::value, |
| 2306 | void |
| 2307 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2308 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2309 | operator*=(const _Expr& __v) const; |
| 2310 | |
| 2311 | template <class _Expr> |
| 2312 | typename enable_if |
| 2313 | < |
| 2314 | __is_val_expr<_Expr>::value, |
| 2315 | void |
| 2316 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2317 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2318 | operator/=(const _Expr& __v) const; |
| 2319 | |
| 2320 | template <class _Expr> |
| 2321 | typename enable_if |
| 2322 | < |
| 2323 | __is_val_expr<_Expr>::value, |
| 2324 | void |
| 2325 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2326 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2327 | operator%=(const _Expr& __v) const; |
| 2328 | |
| 2329 | template <class _Expr> |
| 2330 | typename enable_if |
| 2331 | < |
| 2332 | __is_val_expr<_Expr>::value, |
| 2333 | void |
| 2334 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2335 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2336 | operator+=(const _Expr& __v) const; |
| 2337 | |
| 2338 | template <class _Expr> |
| 2339 | typename enable_if |
| 2340 | < |
| 2341 | __is_val_expr<_Expr>::value, |
| 2342 | void |
| 2343 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2344 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2345 | operator-=(const _Expr& __v) const; |
| 2346 | |
| 2347 | template <class _Expr> |
| 2348 | typename enable_if |
| 2349 | < |
| 2350 | __is_val_expr<_Expr>::value, |
| 2351 | void |
| 2352 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2353 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2354 | operator^=(const _Expr& __v) const; |
| 2355 | |
| 2356 | template <class _Expr> |
| 2357 | typename enable_if |
| 2358 | < |
| 2359 | __is_val_expr<_Expr>::value, |
| 2360 | void |
| 2361 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2362 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2363 | operator&=(const _Expr& __v) const; |
| 2364 | |
| 2365 | template <class _Expr> |
| 2366 | typename enable_if |
| 2367 | < |
| 2368 | __is_val_expr<_Expr>::value, |
| 2369 | void |
| 2370 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2371 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2372 | operator|=(const _Expr& __v) const; |
| 2373 | |
| 2374 | template <class _Expr> |
| 2375 | typename enable_if |
| 2376 | < |
| 2377 | __is_val_expr<_Expr>::value, |
| 2378 | void |
| 2379 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2380 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2381 | operator<<=(const _Expr& __v) const; |
| 2382 | |
| 2383 | template <class _Expr> |
| 2384 | typename enable_if |
| 2385 | < |
| 2386 | __is_val_expr<_Expr>::value, |
| 2387 | void |
| 2388 | >::type |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2389 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2390 | operator>>=(const _Expr& __v) const; |
| 2391 | |
Eric Fiselier | b9f37ca | 2019-12-12 20:48:11 -0500 | [diff] [blame] | 2392 | indirect_array(const indirect_array&) = default; |
| 2393 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2394 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2395 | const indirect_array& operator=(const indirect_array& __ia) const; |
| 2396 | |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2397 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2398 | void operator=(const value_type& __x) const; |
| 2399 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2400 | private: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2401 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2402 | indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) |
| 2403 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
| 2404 | __1d_(__ia) |
| 2405 | {} |
| 2406 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 2407 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2408 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2409 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2410 | indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v) |
| 2411 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 2412 | __1d_(std::move(__ia)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2413 | {} |
| 2414 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2415 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2416 | |
| 2417 | template <class> friend class valarray; |
| 2418 | }; |
| 2419 | |
| 2420 | template <class _Tp> |
| 2421 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2422 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2423 | typename enable_if |
| 2424 | < |
| 2425 | __is_val_expr<_Expr>::value, |
| 2426 | void |
| 2427 | >::type |
| 2428 | indirect_array<_Tp>::operator=(const _Expr& __v) const |
| 2429 | { |
| 2430 | size_t __n = __1d_.size(); |
| 2431 | for (size_t __i = 0; __i < __n; ++__i) |
| 2432 | __vp_[__1d_[__i]] = __v[__i]; |
| 2433 | } |
| 2434 | |
| 2435 | template <class _Tp> |
| 2436 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2437 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2438 | typename enable_if |
| 2439 | < |
| 2440 | __is_val_expr<_Expr>::value, |
| 2441 | void |
| 2442 | >::type |
| 2443 | indirect_array<_Tp>::operator*=(const _Expr& __v) const |
| 2444 | { |
| 2445 | size_t __n = __1d_.size(); |
| 2446 | for (size_t __i = 0; __i < __n; ++__i) |
| 2447 | __vp_[__1d_[__i]] *= __v[__i]; |
| 2448 | } |
| 2449 | |
| 2450 | template <class _Tp> |
| 2451 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2452 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2453 | typename enable_if |
| 2454 | < |
| 2455 | __is_val_expr<_Expr>::value, |
| 2456 | void |
| 2457 | >::type |
| 2458 | indirect_array<_Tp>::operator/=(const _Expr& __v) const |
| 2459 | { |
| 2460 | size_t __n = __1d_.size(); |
| 2461 | for (size_t __i = 0; __i < __n; ++__i) |
| 2462 | __vp_[__1d_[__i]] /= __v[__i]; |
| 2463 | } |
| 2464 | |
| 2465 | template <class _Tp> |
| 2466 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2467 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2468 | typename enable_if |
| 2469 | < |
| 2470 | __is_val_expr<_Expr>::value, |
| 2471 | void |
| 2472 | >::type |
| 2473 | indirect_array<_Tp>::operator%=(const _Expr& __v) const |
| 2474 | { |
| 2475 | size_t __n = __1d_.size(); |
| 2476 | for (size_t __i = 0; __i < __n; ++__i) |
| 2477 | __vp_[__1d_[__i]] %= __v[__i]; |
| 2478 | } |
| 2479 | |
| 2480 | template <class _Tp> |
| 2481 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2482 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2483 | typename enable_if |
| 2484 | < |
| 2485 | __is_val_expr<_Expr>::value, |
| 2486 | void |
| 2487 | >::type |
| 2488 | indirect_array<_Tp>::operator+=(const _Expr& __v) const |
| 2489 | { |
| 2490 | size_t __n = __1d_.size(); |
| 2491 | for (size_t __i = 0; __i < __n; ++__i) |
| 2492 | __vp_[__1d_[__i]] += __v[__i]; |
| 2493 | } |
| 2494 | |
| 2495 | template <class _Tp> |
| 2496 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2497 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2498 | typename enable_if |
| 2499 | < |
| 2500 | __is_val_expr<_Expr>::value, |
| 2501 | void |
| 2502 | >::type |
| 2503 | indirect_array<_Tp>::operator-=(const _Expr& __v) const |
| 2504 | { |
| 2505 | size_t __n = __1d_.size(); |
| 2506 | for (size_t __i = 0; __i < __n; ++__i) |
| 2507 | __vp_[__1d_[__i]] -= __v[__i]; |
| 2508 | } |
| 2509 | |
| 2510 | template <class _Tp> |
| 2511 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2512 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2513 | typename enable_if |
| 2514 | < |
| 2515 | __is_val_expr<_Expr>::value, |
| 2516 | void |
| 2517 | >::type |
| 2518 | indirect_array<_Tp>::operator^=(const _Expr& __v) const |
| 2519 | { |
| 2520 | size_t __n = __1d_.size(); |
| 2521 | for (size_t __i = 0; __i < __n; ++__i) |
| 2522 | __vp_[__1d_[__i]] ^= __v[__i]; |
| 2523 | } |
| 2524 | |
| 2525 | template <class _Tp> |
| 2526 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2527 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2528 | typename enable_if |
| 2529 | < |
| 2530 | __is_val_expr<_Expr>::value, |
| 2531 | void |
| 2532 | >::type |
| 2533 | indirect_array<_Tp>::operator&=(const _Expr& __v) const |
| 2534 | { |
| 2535 | size_t __n = __1d_.size(); |
| 2536 | for (size_t __i = 0; __i < __n; ++__i) |
| 2537 | __vp_[__1d_[__i]] &= __v[__i]; |
| 2538 | } |
| 2539 | |
| 2540 | template <class _Tp> |
| 2541 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2542 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2543 | typename enable_if |
| 2544 | < |
| 2545 | __is_val_expr<_Expr>::value, |
| 2546 | void |
| 2547 | >::type |
| 2548 | indirect_array<_Tp>::operator|=(const _Expr& __v) const |
| 2549 | { |
| 2550 | size_t __n = __1d_.size(); |
| 2551 | for (size_t __i = 0; __i < __n; ++__i) |
| 2552 | __vp_[__1d_[__i]] |= __v[__i]; |
| 2553 | } |
| 2554 | |
| 2555 | template <class _Tp> |
| 2556 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2557 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2558 | typename enable_if |
| 2559 | < |
| 2560 | __is_val_expr<_Expr>::value, |
| 2561 | void |
| 2562 | >::type |
| 2563 | indirect_array<_Tp>::operator<<=(const _Expr& __v) const |
| 2564 | { |
| 2565 | size_t __n = __1d_.size(); |
| 2566 | for (size_t __i = 0; __i < __n; ++__i) |
| 2567 | __vp_[__1d_[__i]] <<= __v[__i]; |
| 2568 | } |
| 2569 | |
| 2570 | template <class _Tp> |
| 2571 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2572 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2573 | typename enable_if |
| 2574 | < |
| 2575 | __is_val_expr<_Expr>::value, |
| 2576 | void |
| 2577 | >::type |
| 2578 | indirect_array<_Tp>::operator>>=(const _Expr& __v) const |
| 2579 | { |
| 2580 | size_t __n = __1d_.size(); |
| 2581 | for (size_t __i = 0; __i < __n; ++__i) |
| 2582 | __vp_[__1d_[__i]] >>= __v[__i]; |
| 2583 | } |
| 2584 | |
| 2585 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2586 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2587 | const indirect_array<_Tp>& |
| 2588 | indirect_array<_Tp>::operator=(const indirect_array& __ia) const |
| 2589 | { |
| 2590 | typedef const size_t* _Ip; |
| 2591 | const value_type* __s = __ia.__vp_; |
| 2592 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; |
| 2593 | __i != __e; ++__i, ++__j) |
| 2594 | __vp_[*__i] = __s[*__j]; |
| 2595 | return *this; |
| 2596 | } |
| 2597 | |
| 2598 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2599 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2600 | void |
| 2601 | indirect_array<_Tp>::operator=(const value_type& __x) const |
| 2602 | { |
| 2603 | typedef const size_t* _Ip; |
| 2604 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) |
| 2605 | __vp_[*__i] = __x; |
| 2606 | } |
| 2607 | |
| 2608 | template <class _ValExpr> |
| 2609 | class __indirect_expr |
| 2610 | { |
Nikolas Klauser | c9e524e | 2022-09-06 00:33:34 +0200 | [diff] [blame] | 2611 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2612 | public: |
| 2613 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2614 | typedef value_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2615 | |
| 2616 | private: |
| 2617 | _ValExpr __expr_; |
| 2618 | valarray<size_t> __1d_; |
| 2619 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2620 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2621 | __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) |
| 2622 | : __expr_(__e), |
| 2623 | __1d_(__ia) |
| 2624 | {} |
| 2625 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 2626 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2627 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2628 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2629 | __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e) |
| 2630 | : __expr_(__e), |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 2631 | __1d_(std::move(__ia)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2632 | {} |
| 2633 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2634 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2635 | |
| 2636 | public: |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2637 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2638 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2639 | {return __expr_[__1d_[__i]];} |
| 2640 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2641 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2642 | size_t size() const {return __1d_.size();} |
| 2643 | |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2644 | template <class> friend class __val_expr; |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 2645 | template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2646 | }; |
| 2647 | |
| 2648 | template<class _ValExpr> |
| 2649 | class __val_expr |
| 2650 | { |
Nikolas Klauser | c9e524e | 2022-09-06 00:33:34 +0200 | [diff] [blame] | 2651 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2652 | |
| 2653 | _ValExpr __expr_; |
| 2654 | public: |
| 2655 | typedef typename _RmExpr::value_type value_type; |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2656 | typedef typename _RmExpr::__result_type __result_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2657 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2658 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2659 | explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {} |
| 2660 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2661 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2662 | __result_type operator[](size_t __i) const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2663 | {return __expr_[__i];} |
| 2664 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2665 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2666 | __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2667 | { |
| 2668 | typedef __slice_expr<_ValExpr> _NewExpr; |
| 2669 | return __val_expr< _NewExpr >(_NewExpr(__s, __expr_)); |
| 2670 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2671 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2672 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2673 | __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2674 | { |
| 2675 | typedef __indirect_expr<_ValExpr> _NewExpr; |
| 2676 | return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_)); |
| 2677 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2678 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2679 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2680 | __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2681 | { |
| 2682 | typedef __mask_expr<_ValExpr> _NewExpr; |
| 2683 | return __val_expr< _NewExpr >( _NewExpr(__vb, __expr_)); |
| 2684 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2685 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2686 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2687 | __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const |
Eric Fiselier | 7b31ed0 | 2019-04-02 08:05:23 +0000 | [diff] [blame] | 2688 | { |
| 2689 | typedef __indirect_expr<_ValExpr> _NewExpr; |
| 2690 | return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_)); |
| 2691 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2692 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2693 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2694 | __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > |
| 2695 | operator+() const |
| 2696 | { |
| 2697 | typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr; |
| 2698 | return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_)); |
| 2699 | } |
| 2700 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2701 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2702 | __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > |
| 2703 | operator-() const |
| 2704 | { |
| 2705 | typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr; |
| 2706 | return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_)); |
| 2707 | } |
| 2708 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2709 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2710 | __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > |
| 2711 | operator~() const |
| 2712 | { |
| 2713 | typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr; |
| 2714 | return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_)); |
| 2715 | } |
| 2716 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2717 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2718 | __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > |
| 2719 | operator!() const |
| 2720 | { |
| 2721 | typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr; |
| 2722 | return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_)); |
| 2723 | } |
| 2724 | |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2725 | operator valarray<__result_type>() const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2726 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2727 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2728 | size_t size() const {return __expr_.size();} |
| 2729 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2730 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2731 | __result_type sum() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2732 | { |
| 2733 | size_t __n = __expr_.size(); |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2734 | __result_type __r = __n ? __expr_[0] : __result_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2735 | for (size_t __i = 1; __i < __n; ++__i) |
| 2736 | __r += __expr_[__i]; |
| 2737 | return __r; |
| 2738 | } |
| 2739 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2740 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2741 | __result_type min() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2742 | { |
| 2743 | size_t __n = size(); |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2744 | __result_type __r = __n ? (*this)[0] : __result_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2745 | for (size_t __i = 1; __i < __n; ++__i) |
| 2746 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2747 | __result_type __x = __expr_[__i]; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2748 | if (__x < __r) |
| 2749 | __r = __x; |
| 2750 | } |
| 2751 | return __r; |
| 2752 | } |
| 2753 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2754 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2755 | __result_type max() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2756 | { |
| 2757 | size_t __n = size(); |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2758 | __result_type __r = __n ? (*this)[0] : __result_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2759 | for (size_t __i = 1; __i < __n; ++__i) |
| 2760 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2761 | __result_type __x = __expr_[__i]; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2762 | if (__r < __x) |
| 2763 | __r = __x; |
| 2764 | } |
| 2765 | return __r; |
| 2766 | } |
| 2767 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2768 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2769 | __val_expr<__shift_expr<_ValExpr> > shift (int __i) const |
| 2770 | {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));} |
| 2771 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2772 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2773 | __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const |
| 2774 | {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));} |
| 2775 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2776 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2777 | __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> > |
| 2778 | apply(value_type __f(value_type)) const |
| 2779 | { |
| 2780 | typedef __apply_expr<value_type, value_type(*)(value_type)> _Op; |
| 2781 | typedef _UnaryOp<_Op, _ValExpr> _NewExpr; |
| 2782 | return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); |
| 2783 | } |
| 2784 | |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2785 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2786 | __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> > |
| 2787 | apply(value_type __f(const value_type&)) const |
| 2788 | { |
| 2789 | typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op; |
| 2790 | typedef _UnaryOp<_Op, _ValExpr> _NewExpr; |
| 2791 | return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); |
| 2792 | } |
| 2793 | }; |
| 2794 | |
| 2795 | template<class _ValExpr> |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2796 | __val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2797 | { |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2798 | valarray<__result_type> __r; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2799 | size_t __n = __expr_.size(); |
| 2800 | if (__n) |
| 2801 | { |
| 2802 | __r.__begin_ = |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2803 | __r.__end_ = allocator<__result_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2804 | for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 2805 | ::new ((void*)__r.__end_) __result_type(__expr_[__i]); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2806 | } |
| 2807 | return __r; |
| 2808 | } |
| 2809 | |
| 2810 | // valarray |
| 2811 | |
| 2812 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2813 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2814 | valarray<_Tp>::valarray(size_t __n) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2815 | : __begin_(nullptr), |
| 2816 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2817 | { |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2818 | if (__n) |
| 2819 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2820 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2821 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2822 | try |
| 2823 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2824 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2825 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2826 | ::new ((void*)__end_) value_type(); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2827 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2828 | } |
| 2829 | catch (...) |
| 2830 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2831 | __clear(__n); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2832 | throw; |
| 2833 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2834 | #endif // _LIBCPP_NO_EXCEPTIONS |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 2835 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2836 | } |
| 2837 | |
| 2838 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2839 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2840 | valarray<_Tp>::valarray(const value_type& __x, size_t __n) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2841 | : __begin_(nullptr), |
| 2842 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2843 | { |
| 2844 | resize(__n, __x); |
| 2845 | } |
| 2846 | |
| 2847 | template <class _Tp> |
| 2848 | valarray<_Tp>::valarray(const value_type* __p, size_t __n) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2849 | : __begin_(nullptr), |
| 2850 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2851 | { |
| 2852 | if (__n) |
| 2853 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2854 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2855 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2856 | try |
| 2857 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2858 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2859 | for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2860 | ::new ((void*)__end_) value_type(*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2861 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2862 | } |
| 2863 | catch (...) |
| 2864 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2865 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2866 | throw; |
| 2867 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2868 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2869 | } |
| 2870 | } |
| 2871 | |
| 2872 | template <class _Tp> |
| 2873 | valarray<_Tp>::valarray(const valarray& __v) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2874 | : __begin_(nullptr), |
| 2875 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2876 | { |
| 2877 | if (__v.size()) |
| 2878 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2879 | __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2880 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2881 | try |
| 2882 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2883 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2884 | for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2885 | ::new ((void*)__end_) value_type(*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2886 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2887 | } |
| 2888 | catch (...) |
| 2889 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2890 | __clear(__v.size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2891 | throw; |
| 2892 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2893 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2894 | } |
| 2895 | } |
| 2896 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 2897 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2898 | |
| 2899 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 2900 | inline |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 2901 | valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2902 | : __begin_(__v.__begin_), |
| 2903 | __end_(__v.__end_) |
| 2904 | { |
| 2905 | __v.__begin_ = __v.__end_ = nullptr; |
| 2906 | } |
| 2907 | |
| 2908 | template <class _Tp> |
| 2909 | valarray<_Tp>::valarray(initializer_list<value_type> __il) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2910 | : __begin_(nullptr), |
| 2911 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2912 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2913 | const size_t __n = __il.size(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2914 | if (__n) |
| 2915 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2916 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2917 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2918 | try |
| 2919 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2920 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2921 | size_t __n_left = __n; |
| 2922 | for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2923 | ::new ((void*)__end_) value_type(*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2924 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2925 | } |
| 2926 | catch (...) |
| 2927 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2928 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2929 | throw; |
| 2930 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2931 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2932 | } |
| 2933 | } |
| 2934 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2935 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2936 | |
| 2937 | template <class _Tp> |
| 2938 | valarray<_Tp>::valarray(const slice_array<value_type>& __sa) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2939 | : __begin_(nullptr), |
| 2940 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2941 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2942 | const size_t __n = __sa.__size_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2943 | if (__n) |
| 2944 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2945 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2946 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2947 | try |
| 2948 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2949 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2950 | size_t __n_left = __n; |
| 2951 | for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2952 | ::new ((void*)__end_) value_type(*__p); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2953 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2954 | } |
| 2955 | catch (...) |
| 2956 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2957 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2958 | throw; |
| 2959 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2960 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2961 | } |
| 2962 | } |
| 2963 | |
| 2964 | template <class _Tp> |
| 2965 | valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2966 | : __begin_(nullptr), |
| 2967 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2968 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2969 | const size_t __n = __ga.__1d_.size(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2970 | if (__n) |
| 2971 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 2972 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2973 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2974 | try |
| 2975 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2976 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2977 | typedef const size_t* _Ip; |
| 2978 | const value_type* __s = __ga.__vp_; |
| 2979 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; |
| 2980 | __i != __e; ++__i, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 2981 | ::new ((void*)__end_) value_type(__s[*__i]); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2982 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2983 | } |
| 2984 | catch (...) |
| 2985 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2986 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2987 | throw; |
| 2988 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 2989 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2990 | } |
| 2991 | } |
| 2992 | |
| 2993 | template <class _Tp> |
| 2994 | valarray<_Tp>::valarray(const mask_array<value_type>& __ma) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 2995 | : __begin_(nullptr), |
| 2996 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2997 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 2998 | const size_t __n = __ma.__1d_.size(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2999 | if (__n) |
| 3000 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3001 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3002 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3003 | try |
| 3004 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3005 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3006 | typedef const size_t* _Ip; |
| 3007 | const value_type* __s = __ma.__vp_; |
| 3008 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; |
| 3009 | __i != __e; ++__i, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3010 | ::new ((void*)__end_) value_type(__s[*__i]); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3011 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3012 | } |
| 3013 | catch (...) |
| 3014 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3015 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3016 | throw; |
| 3017 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3018 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3019 | } |
| 3020 | } |
| 3021 | |
| 3022 | template <class _Tp> |
| 3023 | valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 3024 | : __begin_(nullptr), |
| 3025 | __end_(nullptr) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3026 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3027 | const size_t __n = __ia.__1d_.size(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3028 | if (__n) |
| 3029 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3030 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3031 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3032 | try |
| 3033 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3034 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3035 | typedef const size_t* _Ip; |
| 3036 | const value_type* __s = __ia.__vp_; |
| 3037 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; |
| 3038 | __i != __e; ++__i, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3039 | ::new ((void*)__end_) value_type(__s[*__i]); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3040 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3041 | } |
| 3042 | catch (...) |
| 3043 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3044 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3045 | throw; |
| 3046 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3047 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3048 | } |
| 3049 | } |
| 3050 | |
| 3051 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3052 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3053 | valarray<_Tp>::~valarray() |
| 3054 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3055 | __clear(size()); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3056 | } |
| 3057 | |
| 3058 | template <class _Tp> |
| 3059 | valarray<_Tp>& |
| 3060 | valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) |
| 3061 | { |
| 3062 | size_t __n = __l - __f; |
| 3063 | if (size() != __n) |
| 3064 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3065 | __clear(size()); |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3066 | __begin_ = allocator<value_type>().allocate(__n); |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3067 | __end_ = __begin_ + __n; |
| 3068 | _VSTD::uninitialized_copy(__f, __l, __begin_); |
| 3069 | } else { |
| 3070 | _VSTD::copy(__f, __l, __begin_); |
| 3071 | } |
| 3072 | return *this; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3073 | } |
| 3074 | |
| 3075 | template <class _Tp> |
| 3076 | valarray<_Tp>& |
| 3077 | valarray<_Tp>::operator=(const valarray& __v) |
| 3078 | { |
Mark de Wever | 357a1fc | 2021-09-28 19:15:18 +0200 | [diff] [blame] | 3079 | if (this != _VSTD::addressof(__v)) |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3080 | return __assign_range(__v.__begin_, __v.__end_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3081 | return *this; |
| 3082 | } |
| 3083 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 3084 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3085 | |
| 3086 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3087 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3088 | valarray<_Tp>& |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 3089 | valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3090 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3091 | __clear(size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3092 | __begin_ = __v.__begin_; |
| 3093 | __end_ = __v.__end_; |
| 3094 | __v.__begin_ = nullptr; |
| 3095 | __v.__end_ = nullptr; |
| 3096 | return *this; |
| 3097 | } |
| 3098 | |
| 3099 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3100 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3101 | valarray<_Tp>& |
| 3102 | valarray<_Tp>::operator=(initializer_list<value_type> __il) |
| 3103 | { |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3104 | return __assign_range(__il.begin(), __il.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3105 | } |
| 3106 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3107 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3108 | |
| 3109 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3110 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3111 | valarray<_Tp>& |
| 3112 | valarray<_Tp>::operator=(const value_type& __x) |
| 3113 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3114 | _VSTD::fill(__begin_, __end_, __x); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3115 | return *this; |
| 3116 | } |
| 3117 | |
| 3118 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3119 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3120 | valarray<_Tp>& |
| 3121 | valarray<_Tp>::operator=(const slice_array<value_type>& __sa) |
| 3122 | { |
| 3123 | value_type* __t = __begin_; |
| 3124 | const value_type* __s = __sa.__vp_; |
| 3125 | for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t) |
| 3126 | *__t = *__s; |
| 3127 | return *this; |
| 3128 | } |
| 3129 | |
| 3130 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3131 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3132 | valarray<_Tp>& |
| 3133 | valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) |
| 3134 | { |
| 3135 | typedef const size_t* _Ip; |
| 3136 | value_type* __t = __begin_; |
| 3137 | const value_type* __s = __ga.__vp_; |
| 3138 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; |
| 3139 | __i != __e; ++__i, ++__t) |
| 3140 | *__t = __s[*__i]; |
| 3141 | return *this; |
| 3142 | } |
| 3143 | |
| 3144 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3145 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3146 | valarray<_Tp>& |
| 3147 | valarray<_Tp>::operator=(const mask_array<value_type>& __ma) |
| 3148 | { |
| 3149 | typedef const size_t* _Ip; |
| 3150 | value_type* __t = __begin_; |
| 3151 | const value_type* __s = __ma.__vp_; |
| 3152 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; |
| 3153 | __i != __e; ++__i, ++__t) |
| 3154 | *__t = __s[*__i]; |
| 3155 | return *this; |
| 3156 | } |
| 3157 | |
| 3158 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3159 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3160 | valarray<_Tp>& |
| 3161 | valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) |
| 3162 | { |
| 3163 | typedef const size_t* _Ip; |
| 3164 | value_type* __t = __begin_; |
| 3165 | const value_type* __s = __ia.__vp_; |
| 3166 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; |
| 3167 | __i != __e; ++__i, ++__t) |
| 3168 | *__t = __s[*__i]; |
| 3169 | return *this; |
| 3170 | } |
| 3171 | |
| 3172 | template <class _Tp> |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 3173 | template <class _ValExpr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3174 | inline |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 3175 | valarray<_Tp>& |
| 3176 | valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) |
| 3177 | { |
| 3178 | size_t __n = __v.size(); |
| 3179 | if (size() != __n) |
| 3180 | resize(__n); |
| 3181 | value_type* __t = __begin_; |
| 3182 | for (size_t __i = 0; __i != __n; ++__t, ++__i) |
Arthur O'Dwyer | 66bf60a | 2021-05-29 13:09:07 -0400 | [diff] [blame] | 3183 | *__t = __result_type(__v[__i]); |
Howard Hinnant | 329cd41 | 2011-07-27 23:19:59 +0000 | [diff] [blame] | 3184 | return *this; |
| 3185 | } |
| 3186 | |
| 3187 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3188 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3189 | __val_expr<__slice_expr<const valarray<_Tp>&> > |
| 3190 | valarray<_Tp>::operator[](slice __s) const |
| 3191 | { |
| 3192 | return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this)); |
| 3193 | } |
| 3194 | |
| 3195 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3196 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3197 | slice_array<_Tp> |
| 3198 | valarray<_Tp>::operator[](slice __s) |
| 3199 | { |
| 3200 | return slice_array<value_type>(__s, *this); |
| 3201 | } |
| 3202 | |
| 3203 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3204 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3205 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3206 | valarray<_Tp>::operator[](const gslice& __gs) const |
| 3207 | { |
| 3208 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this)); |
| 3209 | } |
| 3210 | |
| 3211 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3212 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3213 | gslice_array<_Tp> |
| 3214 | valarray<_Tp>::operator[](const gslice& __gs) |
| 3215 | { |
| 3216 | return gslice_array<value_type>(__gs, *this); |
| 3217 | } |
| 3218 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 3219 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3220 | |
| 3221 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3222 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3223 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3224 | valarray<_Tp>::operator[](gslice&& __gs) const |
| 3225 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3226 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3227 | } |
| 3228 | |
| 3229 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3230 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3231 | gslice_array<_Tp> |
| 3232 | valarray<_Tp>::operator[](gslice&& __gs) |
| 3233 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3234 | return gslice_array<value_type>(std::move(__gs), *this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3235 | } |
| 3236 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3237 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3238 | |
| 3239 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3240 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3241 | __val_expr<__mask_expr<const valarray<_Tp>&> > |
| 3242 | valarray<_Tp>::operator[](const valarray<bool>& __vb) const |
| 3243 | { |
| 3244 | return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this)); |
| 3245 | } |
| 3246 | |
| 3247 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3248 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3249 | mask_array<_Tp> |
| 3250 | valarray<_Tp>::operator[](const valarray<bool>& __vb) |
| 3251 | { |
| 3252 | return mask_array<value_type>(__vb, *this); |
| 3253 | } |
| 3254 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 3255 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3256 | |
| 3257 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3258 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3259 | __val_expr<__mask_expr<const valarray<_Tp>&> > |
| 3260 | valarray<_Tp>::operator[](valarray<bool>&& __vb) const |
| 3261 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3262 | return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3263 | } |
| 3264 | |
| 3265 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3266 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3267 | mask_array<_Tp> |
| 3268 | valarray<_Tp>::operator[](valarray<bool>&& __vb) |
| 3269 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3270 | return mask_array<value_type>(std::move(__vb), *this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3271 | } |
| 3272 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3273 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3274 | |
| 3275 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3276 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3277 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3278 | valarray<_Tp>::operator[](const valarray<size_t>& __vs) const |
| 3279 | { |
| 3280 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this)); |
| 3281 | } |
| 3282 | |
| 3283 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3284 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3285 | indirect_array<_Tp> |
| 3286 | valarray<_Tp>::operator[](const valarray<size_t>& __vs) |
| 3287 | { |
| 3288 | return indirect_array<value_type>(__vs, *this); |
| 3289 | } |
| 3290 | |
Eric Fiselier | 3b0b81f | 2017-04-19 00:23:45 +0000 | [diff] [blame] | 3291 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3292 | |
| 3293 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3294 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3295 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3296 | valarray<_Tp>::operator[](valarray<size_t>&& __vs) const |
| 3297 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3298 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3299 | } |
| 3300 | |
| 3301 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3302 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3303 | indirect_array<_Tp> |
| 3304 | valarray<_Tp>::operator[](valarray<size_t>&& __vs) |
| 3305 | { |
Corentin Jabot | cfb8a91 | 2022-02-24 19:54:00 -0500 | [diff] [blame] | 3306 | return indirect_array<value_type>(std::move(__vs), *this); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3307 | } |
| 3308 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3309 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3310 | |
| 3311 | template <class _Tp> |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 3312 | inline |
| 3313 | __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3314 | valarray<_Tp>::operator+() const |
| 3315 | { |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 3316 | using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>; |
| 3317 | return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3318 | } |
| 3319 | |
| 3320 | template <class _Tp> |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 3321 | inline |
| 3322 | __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3323 | valarray<_Tp>::operator-() const |
| 3324 | { |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 3325 | using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>; |
| 3326 | return __val_expr<_Op>(_Op(negate<_Tp>(), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3327 | } |
| 3328 | |
| 3329 | template <class _Tp> |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 3330 | inline |
| 3331 | __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3332 | valarray<_Tp>::operator~() const |
| 3333 | { |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 3334 | using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>; |
| 3335 | return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3336 | } |
| 3337 | |
| 3338 | template <class _Tp> |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 3339 | inline |
| 3340 | __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3341 | valarray<_Tp>::operator!() const |
| 3342 | { |
Louis Dionne | 12a2e57 | 2022-05-05 12:24:43 -0400 | [diff] [blame] | 3343 | using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>; |
| 3344 | return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3345 | } |
| 3346 | |
| 3347 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3348 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3349 | valarray<_Tp>& |
| 3350 | valarray<_Tp>::operator*=(const value_type& __x) |
| 3351 | { |
| 3352 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3353 | *__p *= __x; |
| 3354 | return *this; |
| 3355 | } |
| 3356 | |
| 3357 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3358 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3359 | valarray<_Tp>& |
| 3360 | valarray<_Tp>::operator/=(const value_type& __x) |
| 3361 | { |
| 3362 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3363 | *__p /= __x; |
| 3364 | return *this; |
| 3365 | } |
| 3366 | |
| 3367 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3368 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3369 | valarray<_Tp>& |
| 3370 | valarray<_Tp>::operator%=(const value_type& __x) |
| 3371 | { |
| 3372 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3373 | *__p %= __x; |
| 3374 | return *this; |
| 3375 | } |
| 3376 | |
| 3377 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3378 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3379 | valarray<_Tp>& |
| 3380 | valarray<_Tp>::operator+=(const value_type& __x) |
| 3381 | { |
| 3382 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3383 | *__p += __x; |
| 3384 | return *this; |
| 3385 | } |
| 3386 | |
| 3387 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3388 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3389 | valarray<_Tp>& |
| 3390 | valarray<_Tp>::operator-=(const value_type& __x) |
| 3391 | { |
| 3392 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3393 | *__p -= __x; |
| 3394 | return *this; |
| 3395 | } |
| 3396 | |
| 3397 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3398 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3399 | valarray<_Tp>& |
| 3400 | valarray<_Tp>::operator^=(const value_type& __x) |
| 3401 | { |
| 3402 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3403 | *__p ^= __x; |
| 3404 | return *this; |
| 3405 | } |
| 3406 | |
| 3407 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3408 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3409 | valarray<_Tp>& |
| 3410 | valarray<_Tp>::operator&=(const value_type& __x) |
| 3411 | { |
| 3412 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3413 | *__p &= __x; |
| 3414 | return *this; |
| 3415 | } |
| 3416 | |
| 3417 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3418 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3419 | valarray<_Tp>& |
| 3420 | valarray<_Tp>::operator|=(const value_type& __x) |
| 3421 | { |
| 3422 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3423 | *__p |= __x; |
| 3424 | return *this; |
| 3425 | } |
| 3426 | |
| 3427 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3428 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3429 | valarray<_Tp>& |
| 3430 | valarray<_Tp>::operator<<=(const value_type& __x) |
| 3431 | { |
| 3432 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3433 | *__p <<= __x; |
| 3434 | return *this; |
| 3435 | } |
| 3436 | |
| 3437 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3438 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3439 | valarray<_Tp>& |
| 3440 | valarray<_Tp>::operator>>=(const value_type& __x) |
| 3441 | { |
| 3442 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
| 3443 | *__p >>= __x; |
| 3444 | return *this; |
| 3445 | } |
| 3446 | |
| 3447 | template <class _Tp> |
| 3448 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3449 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3450 | typename enable_if |
| 3451 | < |
| 3452 | __is_val_expr<_Expr>::value, |
| 3453 | valarray<_Tp>& |
| 3454 | >::type |
| 3455 | valarray<_Tp>::operator*=(const _Expr& __v) |
| 3456 | { |
| 3457 | size_t __i = 0; |
| 3458 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3459 | *__t *= __v[__i]; |
| 3460 | return *this; |
| 3461 | } |
| 3462 | |
| 3463 | template <class _Tp> |
| 3464 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3465 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3466 | typename enable_if |
| 3467 | < |
| 3468 | __is_val_expr<_Expr>::value, |
| 3469 | valarray<_Tp>& |
| 3470 | >::type |
| 3471 | valarray<_Tp>::operator/=(const _Expr& __v) |
| 3472 | { |
| 3473 | size_t __i = 0; |
| 3474 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3475 | *__t /= __v[__i]; |
| 3476 | return *this; |
| 3477 | } |
| 3478 | |
| 3479 | template <class _Tp> |
| 3480 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3481 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3482 | typename enable_if |
| 3483 | < |
| 3484 | __is_val_expr<_Expr>::value, |
| 3485 | valarray<_Tp>& |
| 3486 | >::type |
| 3487 | valarray<_Tp>::operator%=(const _Expr& __v) |
| 3488 | { |
| 3489 | size_t __i = 0; |
| 3490 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3491 | *__t %= __v[__i]; |
| 3492 | return *this; |
| 3493 | } |
| 3494 | |
| 3495 | template <class _Tp> |
| 3496 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3497 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3498 | typename enable_if |
| 3499 | < |
| 3500 | __is_val_expr<_Expr>::value, |
| 3501 | valarray<_Tp>& |
| 3502 | >::type |
| 3503 | valarray<_Tp>::operator+=(const _Expr& __v) |
| 3504 | { |
| 3505 | size_t __i = 0; |
| 3506 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3507 | *__t += __v[__i]; |
| 3508 | return *this; |
| 3509 | } |
| 3510 | |
| 3511 | template <class _Tp> |
| 3512 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3513 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3514 | typename enable_if |
| 3515 | < |
| 3516 | __is_val_expr<_Expr>::value, |
| 3517 | valarray<_Tp>& |
| 3518 | >::type |
| 3519 | valarray<_Tp>::operator-=(const _Expr& __v) |
| 3520 | { |
| 3521 | size_t __i = 0; |
| 3522 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3523 | *__t -= __v[__i]; |
| 3524 | return *this; |
| 3525 | } |
| 3526 | |
| 3527 | template <class _Tp> |
| 3528 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3529 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3530 | typename enable_if |
| 3531 | < |
| 3532 | __is_val_expr<_Expr>::value, |
| 3533 | valarray<_Tp>& |
| 3534 | >::type |
| 3535 | valarray<_Tp>::operator^=(const _Expr& __v) |
| 3536 | { |
| 3537 | size_t __i = 0; |
| 3538 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3539 | *__t ^= __v[__i]; |
| 3540 | return *this; |
| 3541 | } |
| 3542 | |
| 3543 | template <class _Tp> |
| 3544 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3545 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3546 | typename enable_if |
| 3547 | < |
| 3548 | __is_val_expr<_Expr>::value, |
| 3549 | valarray<_Tp>& |
| 3550 | >::type |
| 3551 | valarray<_Tp>::operator|=(const _Expr& __v) |
| 3552 | { |
| 3553 | size_t __i = 0; |
| 3554 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3555 | *__t |= __v[__i]; |
| 3556 | return *this; |
| 3557 | } |
| 3558 | |
| 3559 | template <class _Tp> |
| 3560 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3561 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3562 | typename enable_if |
| 3563 | < |
| 3564 | __is_val_expr<_Expr>::value, |
| 3565 | valarray<_Tp>& |
| 3566 | >::type |
| 3567 | valarray<_Tp>::operator&=(const _Expr& __v) |
| 3568 | { |
| 3569 | size_t __i = 0; |
| 3570 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3571 | *__t &= __v[__i]; |
| 3572 | return *this; |
| 3573 | } |
| 3574 | |
| 3575 | template <class _Tp> |
| 3576 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3577 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3578 | typename enable_if |
| 3579 | < |
| 3580 | __is_val_expr<_Expr>::value, |
| 3581 | valarray<_Tp>& |
| 3582 | >::type |
| 3583 | valarray<_Tp>::operator<<=(const _Expr& __v) |
| 3584 | { |
| 3585 | size_t __i = 0; |
| 3586 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3587 | *__t <<= __v[__i]; |
| 3588 | return *this; |
| 3589 | } |
| 3590 | |
| 3591 | template <class _Tp> |
| 3592 | template <class _Expr> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3593 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3594 | typename enable_if |
| 3595 | < |
| 3596 | __is_val_expr<_Expr>::value, |
| 3597 | valarray<_Tp>& |
| 3598 | >::type |
| 3599 | valarray<_Tp>::operator>>=(const _Expr& __v) |
| 3600 | { |
| 3601 | size_t __i = 0; |
| 3602 | for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) |
| 3603 | *__t >>= __v[__i]; |
| 3604 | return *this; |
| 3605 | } |
| 3606 | |
| 3607 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3608 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3609 | void |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 3610 | valarray<_Tp>::swap(valarray& __v) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3611 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3612 | _VSTD::swap(__begin_, __v.__begin_); |
| 3613 | _VSTD::swap(__end_, __v.__end_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3614 | } |
| 3615 | |
| 3616 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3617 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3618 | _Tp |
| 3619 | valarray<_Tp>::sum() const |
| 3620 | { |
| 3621 | if (__begin_ == __end_) |
| 3622 | return value_type(); |
| 3623 | const value_type* __p = __begin_; |
| 3624 | _Tp __r = *__p; |
| 3625 | for (++__p; __p != __end_; ++__p) |
| 3626 | __r += *__p; |
| 3627 | return __r; |
| 3628 | } |
| 3629 | |
| 3630 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3631 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3632 | _Tp |
| 3633 | valarray<_Tp>::min() const |
| 3634 | { |
| 3635 | if (__begin_ == __end_) |
| 3636 | return value_type(); |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3637 | return *_VSTD::min_element(__begin_, __end_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3638 | } |
| 3639 | |
| 3640 | template <class _Tp> |
Evgeniy Stepanov | 2fb1cb6 | 2015-11-07 01:22:13 +0000 | [diff] [blame] | 3641 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3642 | _Tp |
| 3643 | valarray<_Tp>::max() const |
| 3644 | { |
| 3645 | if (__begin_ == __end_) |
| 3646 | return value_type(); |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3647 | return *_VSTD::max_element(__begin_, __end_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | template <class _Tp> |
| 3651 | valarray<_Tp> |
| 3652 | valarray<_Tp>::shift(int __i) const |
| 3653 | { |
| 3654 | valarray<value_type> __r; |
| 3655 | size_t __n = size(); |
| 3656 | if (__n) |
| 3657 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3658 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3659 | const value_type* __sb; |
| 3660 | value_type* __tb; |
| 3661 | value_type* __te; |
| 3662 | if (__i >= 0) |
| 3663 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3664 | __i = _VSTD::min(__i, static_cast<int>(__n)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3665 | __sb = __begin_ + __i; |
| 3666 | __tb = __r.__begin_; |
| 3667 | __te = __r.__begin_ + (__n - __i); |
| 3668 | } |
| 3669 | else |
| 3670 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3671 | __i = _VSTD::min(-__i, static_cast<int>(__n)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3672 | __sb = __begin_; |
| 3673 | __tb = __r.__begin_ + __i; |
| 3674 | __te = __r.__begin_ + __n; |
| 3675 | } |
| 3676 | for (; __r.__end_ != __tb; ++__r.__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3677 | ::new ((void*)__r.__end_) value_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3678 | for (; __r.__end_ != __te; ++__r.__end_, ++__sb) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3679 | ::new ((void*)__r.__end_) value_type(*__sb); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3680 | for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3681 | ::new ((void*)__r.__end_) value_type(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3682 | } |
| 3683 | return __r; |
| 3684 | } |
| 3685 | |
| 3686 | template <class _Tp> |
| 3687 | valarray<_Tp> |
| 3688 | valarray<_Tp>::cshift(int __i) const |
| 3689 | { |
| 3690 | valarray<value_type> __r; |
| 3691 | size_t __n = size(); |
| 3692 | if (__n) |
| 3693 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3694 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3695 | __i %= static_cast<int>(__n); |
| 3696 | const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i; |
| 3697 | for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3698 | ::new ((void*)__r.__end_) value_type(*__s); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3699 | for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3700 | ::new ((void*)__r.__end_) value_type(*__s); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3701 | } |
| 3702 | return __r; |
| 3703 | } |
| 3704 | |
| 3705 | template <class _Tp> |
| 3706 | valarray<_Tp> |
| 3707 | valarray<_Tp>::apply(value_type __f(value_type)) const |
| 3708 | { |
| 3709 | valarray<value_type> __r; |
| 3710 | size_t __n = size(); |
| 3711 | if (__n) |
| 3712 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3713 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3714 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3715 | ::new ((void*)__r.__end_) value_type(__f(*__p)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3716 | } |
| 3717 | return __r; |
| 3718 | } |
| 3719 | |
| 3720 | template <class _Tp> |
| 3721 | valarray<_Tp> |
| 3722 | valarray<_Tp>::apply(value_type __f(const value_type&)) const |
| 3723 | { |
| 3724 | valarray<value_type> __r; |
| 3725 | size_t __n = size(); |
| 3726 | if (__n) |
| 3727 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3728 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3729 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3730 | ::new ((void*)__r.__end_) value_type(__f(*__p)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3731 | } |
| 3732 | return __r; |
| 3733 | } |
| 3734 | |
| 3735 | template <class _Tp> |
Eric Fiselier | a119c32 | 2018-10-25 17:43:26 +0000 | [diff] [blame] | 3736 | inline |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3737 | void valarray<_Tp>::__clear(size_t __capacity) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3738 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3739 | if (__begin_ != nullptr) |
| 3740 | { |
| 3741 | while (__end_ != __begin_) |
| 3742 | (--__end_)->~value_type(); |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3743 | allocator<value_type>().deallocate(__begin_, __capacity); |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3744 | __begin_ = __end_ = nullptr; |
| 3745 | } |
Mikhail Maltsev | 59de6f8 | 2018-02-08 11:33:48 +0000 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | template <class _Tp> |
| 3749 | void |
| 3750 | valarray<_Tp>::resize(size_t __n, value_type __x) |
| 3751 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3752 | __clear(size()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3753 | if (__n) |
| 3754 | { |
Louis Dionne | 5ffe515 | 2020-09-28 15:47:49 -0400 | [diff] [blame] | 3755 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3756 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3757 | try |
| 3758 | { |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3759 | #endif // _LIBCPP_NO_EXCEPTIONS |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3760 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
Arthur O'Dwyer | 0c4472a | 2020-12-11 20:30:28 -0500 | [diff] [blame] | 3761 | ::new ((void*)__end_) value_type(__x); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3762 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3763 | } |
| 3764 | catch (...) |
| 3765 | { |
Eric Fiselier | 2856ef8 | 2018-10-25 17:21:30 +0000 | [diff] [blame] | 3766 | __clear(__n); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3767 | throw; |
| 3768 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 3769 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3770 | } |
| 3771 | } |
| 3772 | |
| 3773 | template<class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3774 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3775 | void |
Howard Hinnant | 298aed9 | 2012-07-21 00:51:28 +0000 | [diff] [blame] | 3776 | swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3777 | { |
| 3778 | __x.swap(__y); |
| 3779 | } |
| 3780 | |
| 3781 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3782 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3783 | typename enable_if |
| 3784 | < |
| 3785 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3786 | __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3787 | >::type |
| 3788 | operator*(const _Expr1& __x, const _Expr2& __y) |
| 3789 | { |
| 3790 | typedef typename _Expr1::value_type value_type; |
| 3791 | typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op; |
| 3792 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y)); |
| 3793 | } |
| 3794 | |
| 3795 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3796 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3797 | typename enable_if |
| 3798 | < |
| 3799 | __is_val_expr<_Expr>::value, |
| 3800 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, |
| 3801 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3802 | >::type |
| 3803 | operator*(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3804 | { |
| 3805 | typedef typename _Expr::value_type value_type; |
| 3806 | typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3807 | return __val_expr<_Op>(_Op(multiplies<value_type>(), |
| 3808 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3809 | } |
| 3810 | |
| 3811 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3812 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3813 | typename enable_if |
| 3814 | < |
| 3815 | __is_val_expr<_Expr>::value, |
| 3816 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, |
| 3817 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3818 | >::type |
| 3819 | operator*(const typename _Expr::value_type& __x, const _Expr& __y) |
| 3820 | { |
| 3821 | typedef typename _Expr::value_type value_type; |
| 3822 | typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3823 | return __val_expr<_Op>(_Op(multiplies<value_type>(), |
| 3824 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3825 | } |
| 3826 | |
| 3827 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3828 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3829 | typename enable_if |
| 3830 | < |
| 3831 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3832 | __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3833 | >::type |
| 3834 | operator/(const _Expr1& __x, const _Expr2& __y) |
| 3835 | { |
| 3836 | typedef typename _Expr1::value_type value_type; |
| 3837 | typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op; |
| 3838 | return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y)); |
| 3839 | } |
| 3840 | |
| 3841 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3842 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3843 | typename enable_if |
| 3844 | < |
| 3845 | __is_val_expr<_Expr>::value, |
| 3846 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, |
| 3847 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3848 | >::type |
| 3849 | operator/(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3850 | { |
| 3851 | typedef typename _Expr::value_type value_type; |
| 3852 | typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3853 | return __val_expr<_Op>(_Op(divides<value_type>(), |
| 3854 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3855 | } |
| 3856 | |
| 3857 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3858 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3859 | typename enable_if |
| 3860 | < |
| 3861 | __is_val_expr<_Expr>::value, |
| 3862 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, |
| 3863 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3864 | >::type |
| 3865 | operator/(const typename _Expr::value_type& __x, const _Expr& __y) |
| 3866 | { |
| 3867 | typedef typename _Expr::value_type value_type; |
| 3868 | typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3869 | return __val_expr<_Op>(_Op(divides<value_type>(), |
| 3870 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3871 | } |
| 3872 | |
| 3873 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3874 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3875 | typename enable_if |
| 3876 | < |
| 3877 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3878 | __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3879 | >::type |
| 3880 | operator%(const _Expr1& __x, const _Expr2& __y) |
| 3881 | { |
| 3882 | typedef typename _Expr1::value_type value_type; |
| 3883 | typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op; |
| 3884 | return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y)); |
| 3885 | } |
| 3886 | |
| 3887 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3888 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3889 | typename enable_if |
| 3890 | < |
| 3891 | __is_val_expr<_Expr>::value, |
| 3892 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, |
| 3893 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3894 | >::type |
| 3895 | operator%(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3896 | { |
| 3897 | typedef typename _Expr::value_type value_type; |
| 3898 | typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3899 | return __val_expr<_Op>(_Op(modulus<value_type>(), |
| 3900 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3901 | } |
| 3902 | |
| 3903 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3904 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3905 | typename enable_if |
| 3906 | < |
| 3907 | __is_val_expr<_Expr>::value, |
| 3908 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, |
| 3909 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3910 | >::type |
| 3911 | operator%(const typename _Expr::value_type& __x, const _Expr& __y) |
| 3912 | { |
| 3913 | typedef typename _Expr::value_type value_type; |
| 3914 | typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3915 | return __val_expr<_Op>(_Op(modulus<value_type>(), |
| 3916 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3917 | } |
| 3918 | |
| 3919 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3920 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3921 | typename enable_if |
| 3922 | < |
| 3923 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3924 | __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3925 | >::type |
| 3926 | operator+(const _Expr1& __x, const _Expr2& __y) |
| 3927 | { |
| 3928 | typedef typename _Expr1::value_type value_type; |
| 3929 | typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op; |
| 3930 | return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y)); |
| 3931 | } |
| 3932 | |
| 3933 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3934 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3935 | typename enable_if |
| 3936 | < |
| 3937 | __is_val_expr<_Expr>::value, |
| 3938 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, |
| 3939 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3940 | >::type |
| 3941 | operator+(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3942 | { |
| 3943 | typedef typename _Expr::value_type value_type; |
| 3944 | typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3945 | return __val_expr<_Op>(_Op(plus<value_type>(), |
| 3946 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3947 | } |
| 3948 | |
| 3949 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3950 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3951 | typename enable_if |
| 3952 | < |
| 3953 | __is_val_expr<_Expr>::value, |
| 3954 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, |
| 3955 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3956 | >::type |
| 3957 | operator+(const typename _Expr::value_type& __x, const _Expr& __y) |
| 3958 | { |
| 3959 | typedef typename _Expr::value_type value_type; |
| 3960 | typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 3961 | return __val_expr<_Op>(_Op(plus<value_type>(), |
| 3962 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 3963 | } |
| 3964 | |
| 3965 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3966 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3967 | typename enable_if |
| 3968 | < |
| 3969 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 3970 | __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3971 | >::type |
| 3972 | operator-(const _Expr1& __x, const _Expr2& __y) |
| 3973 | { |
| 3974 | typedef typename _Expr1::value_type value_type; |
| 3975 | typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op; |
| 3976 | return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y)); |
| 3977 | } |
| 3978 | |
| 3979 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3980 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3981 | typename enable_if |
| 3982 | < |
| 3983 | __is_val_expr<_Expr>::value, |
| 3984 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, |
| 3985 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3986 | >::type |
| 3987 | operator-(const _Expr& __x, const typename _Expr::value_type& __y) |
| 3988 | { |
| 3989 | typedef typename _Expr::value_type value_type; |
| 3990 | typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 3991 | return __val_expr<_Op>(_Op(minus<value_type>(), |
| 3992 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 3993 | } |
| 3994 | |
| 3995 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 3996 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3997 | typename enable_if |
| 3998 | < |
| 3999 | __is_val_expr<_Expr>::value, |
| 4000 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, |
| 4001 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4002 | >::type |
| 4003 | operator-(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4004 | { |
| 4005 | typedef typename _Expr::value_type value_type; |
| 4006 | typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4007 | return __val_expr<_Op>(_Op(minus<value_type>(), |
| 4008 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4009 | } |
| 4010 | |
| 4011 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4012 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4013 | typename enable_if |
| 4014 | < |
| 4015 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4016 | __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4017 | >::type |
| 4018 | operator^(const _Expr1& __x, const _Expr2& __y) |
| 4019 | { |
| 4020 | typedef typename _Expr1::value_type value_type; |
| 4021 | typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op; |
| 4022 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y)); |
| 4023 | } |
| 4024 | |
| 4025 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4026 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4027 | typename enable_if |
| 4028 | < |
| 4029 | __is_val_expr<_Expr>::value, |
| 4030 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, |
| 4031 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4032 | >::type |
| 4033 | operator^(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4034 | { |
| 4035 | typedef typename _Expr::value_type value_type; |
| 4036 | typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4037 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), |
| 4038 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4039 | } |
| 4040 | |
| 4041 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4042 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4043 | typename enable_if |
| 4044 | < |
| 4045 | __is_val_expr<_Expr>::value, |
| 4046 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, |
| 4047 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4048 | >::type |
| 4049 | operator^(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4050 | { |
| 4051 | typedef typename _Expr::value_type value_type; |
| 4052 | typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4053 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), |
| 4054 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4055 | } |
| 4056 | |
| 4057 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4058 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4059 | typename enable_if |
| 4060 | < |
| 4061 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4062 | __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4063 | >::type |
| 4064 | operator&(const _Expr1& __x, const _Expr2& __y) |
| 4065 | { |
| 4066 | typedef typename _Expr1::value_type value_type; |
| 4067 | typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op; |
| 4068 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y)); |
| 4069 | } |
| 4070 | |
| 4071 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4072 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4073 | typename enable_if |
| 4074 | < |
| 4075 | __is_val_expr<_Expr>::value, |
| 4076 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, |
| 4077 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4078 | >::type |
| 4079 | operator&(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4080 | { |
| 4081 | typedef typename _Expr::value_type value_type; |
| 4082 | typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4083 | return __val_expr<_Op>(_Op(bit_and<value_type>(), |
| 4084 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4085 | } |
| 4086 | |
| 4087 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4088 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4089 | typename enable_if |
| 4090 | < |
| 4091 | __is_val_expr<_Expr>::value, |
| 4092 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, |
| 4093 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4094 | >::type |
| 4095 | operator&(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4096 | { |
| 4097 | typedef typename _Expr::value_type value_type; |
| 4098 | typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4099 | return __val_expr<_Op>(_Op(bit_and<value_type>(), |
| 4100 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4101 | } |
| 4102 | |
| 4103 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4104 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4105 | typename enable_if |
| 4106 | < |
| 4107 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4108 | __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4109 | >::type |
| 4110 | operator|(const _Expr1& __x, const _Expr2& __y) |
| 4111 | { |
| 4112 | typedef typename _Expr1::value_type value_type; |
| 4113 | typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op; |
| 4114 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y)); |
| 4115 | } |
| 4116 | |
| 4117 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4118 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4119 | typename enable_if |
| 4120 | < |
| 4121 | __is_val_expr<_Expr>::value, |
| 4122 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, |
| 4123 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4124 | >::type |
| 4125 | operator|(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4126 | { |
| 4127 | typedef typename _Expr::value_type value_type; |
| 4128 | typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4129 | return __val_expr<_Op>(_Op(bit_or<value_type>(), |
| 4130 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4131 | } |
| 4132 | |
| 4133 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4134 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4135 | typename enable_if |
| 4136 | < |
| 4137 | __is_val_expr<_Expr>::value, |
| 4138 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, |
| 4139 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4140 | >::type |
| 4141 | operator|(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4142 | { |
| 4143 | typedef typename _Expr::value_type value_type; |
| 4144 | typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4145 | return __val_expr<_Op>(_Op(bit_or<value_type>(), |
| 4146 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4147 | } |
| 4148 | |
| 4149 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4150 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4151 | typename enable_if |
| 4152 | < |
| 4153 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4154 | __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4155 | >::type |
| 4156 | operator<<(const _Expr1& __x, const _Expr2& __y) |
| 4157 | { |
| 4158 | typedef typename _Expr1::value_type value_type; |
| 4159 | typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op; |
| 4160 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y)); |
| 4161 | } |
| 4162 | |
| 4163 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4164 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4165 | typename enable_if |
| 4166 | < |
| 4167 | __is_val_expr<_Expr>::value, |
| 4168 | __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, |
| 4169 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4170 | >::type |
| 4171 | operator<<(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4172 | { |
| 4173 | typedef typename _Expr::value_type value_type; |
| 4174 | typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4175 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), |
| 4176 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4177 | } |
| 4178 | |
| 4179 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4180 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4181 | typename enable_if |
| 4182 | < |
| 4183 | __is_val_expr<_Expr>::value, |
| 4184 | __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, |
| 4185 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4186 | >::type |
| 4187 | operator<<(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4188 | { |
| 4189 | typedef typename _Expr::value_type value_type; |
| 4190 | typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4191 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), |
| 4192 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4193 | } |
| 4194 | |
| 4195 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4196 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4197 | typename enable_if |
| 4198 | < |
| 4199 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4200 | __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4201 | >::type |
| 4202 | operator>>(const _Expr1& __x, const _Expr2& __y) |
| 4203 | { |
| 4204 | typedef typename _Expr1::value_type value_type; |
| 4205 | typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op; |
| 4206 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y)); |
| 4207 | } |
| 4208 | |
| 4209 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4210 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4211 | typename enable_if |
| 4212 | < |
| 4213 | __is_val_expr<_Expr>::value, |
| 4214 | __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, |
| 4215 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4216 | >::type |
| 4217 | operator>>(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4218 | { |
| 4219 | typedef typename _Expr::value_type value_type; |
| 4220 | typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4221 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), |
| 4222 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4223 | } |
| 4224 | |
| 4225 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4226 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4227 | typename enable_if |
| 4228 | < |
| 4229 | __is_val_expr<_Expr>::value, |
| 4230 | __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, |
| 4231 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4232 | >::type |
| 4233 | operator>>(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4234 | { |
| 4235 | typedef typename _Expr::value_type value_type; |
| 4236 | typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4237 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), |
| 4238 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4239 | } |
| 4240 | |
| 4241 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4242 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4243 | typename enable_if |
| 4244 | < |
| 4245 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4246 | __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4247 | >::type |
| 4248 | operator&&(const _Expr1& __x, const _Expr2& __y) |
| 4249 | { |
| 4250 | typedef typename _Expr1::value_type value_type; |
| 4251 | typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op; |
| 4252 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y)); |
| 4253 | } |
| 4254 | |
| 4255 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4256 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4257 | typename enable_if |
| 4258 | < |
| 4259 | __is_val_expr<_Expr>::value, |
| 4260 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, |
| 4261 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4262 | >::type |
| 4263 | operator&&(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4264 | { |
| 4265 | typedef typename _Expr::value_type value_type; |
| 4266 | typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4267 | return __val_expr<_Op>(_Op(logical_and<value_type>(), |
| 4268 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4269 | } |
| 4270 | |
| 4271 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4272 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4273 | typename enable_if |
| 4274 | < |
| 4275 | __is_val_expr<_Expr>::value, |
| 4276 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, |
| 4277 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4278 | >::type |
| 4279 | operator&&(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4280 | { |
| 4281 | typedef typename _Expr::value_type value_type; |
| 4282 | typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4283 | return __val_expr<_Op>(_Op(logical_and<value_type>(), |
| 4284 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4285 | } |
| 4286 | |
| 4287 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4288 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4289 | typename enable_if |
| 4290 | < |
| 4291 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4292 | __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4293 | >::type |
| 4294 | operator||(const _Expr1& __x, const _Expr2& __y) |
| 4295 | { |
| 4296 | typedef typename _Expr1::value_type value_type; |
| 4297 | typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op; |
| 4298 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y)); |
| 4299 | } |
| 4300 | |
| 4301 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4302 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4303 | typename enable_if |
| 4304 | < |
| 4305 | __is_val_expr<_Expr>::value, |
| 4306 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, |
| 4307 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4308 | >::type |
| 4309 | operator||(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4310 | { |
| 4311 | typedef typename _Expr::value_type value_type; |
| 4312 | typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4313 | return __val_expr<_Op>(_Op(logical_or<value_type>(), |
| 4314 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4315 | } |
| 4316 | |
| 4317 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4318 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4319 | typename enable_if |
| 4320 | < |
| 4321 | __is_val_expr<_Expr>::value, |
| 4322 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, |
| 4323 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4324 | >::type |
| 4325 | operator||(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4326 | { |
| 4327 | typedef typename _Expr::value_type value_type; |
| 4328 | typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4329 | return __val_expr<_Op>(_Op(logical_or<value_type>(), |
| 4330 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4331 | } |
| 4332 | |
| 4333 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4334 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4335 | typename enable_if |
| 4336 | < |
| 4337 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4338 | __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4339 | >::type |
| 4340 | operator==(const _Expr1& __x, const _Expr2& __y) |
| 4341 | { |
| 4342 | typedef typename _Expr1::value_type value_type; |
| 4343 | typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op; |
| 4344 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y)); |
| 4345 | } |
| 4346 | |
| 4347 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4348 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4349 | typename enable_if |
| 4350 | < |
| 4351 | __is_val_expr<_Expr>::value, |
| 4352 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, |
| 4353 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4354 | >::type |
| 4355 | operator==(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4356 | { |
| 4357 | typedef typename _Expr::value_type value_type; |
| 4358 | typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4359 | return __val_expr<_Op>(_Op(equal_to<value_type>(), |
| 4360 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4361 | } |
| 4362 | |
| 4363 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4364 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4365 | typename enable_if |
| 4366 | < |
| 4367 | __is_val_expr<_Expr>::value, |
| 4368 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, |
| 4369 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4370 | >::type |
| 4371 | operator==(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4372 | { |
| 4373 | typedef typename _Expr::value_type value_type; |
| 4374 | typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4375 | return __val_expr<_Op>(_Op(equal_to<value_type>(), |
| 4376 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4377 | } |
| 4378 | |
| 4379 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4380 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4381 | typename enable_if |
| 4382 | < |
| 4383 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4384 | __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4385 | >::type |
| 4386 | operator!=(const _Expr1& __x, const _Expr2& __y) |
| 4387 | { |
| 4388 | typedef typename _Expr1::value_type value_type; |
| 4389 | typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op; |
| 4390 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y)); |
| 4391 | } |
| 4392 | |
| 4393 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4394 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4395 | typename enable_if |
| 4396 | < |
| 4397 | __is_val_expr<_Expr>::value, |
| 4398 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, |
| 4399 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4400 | >::type |
| 4401 | operator!=(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4402 | { |
| 4403 | typedef typename _Expr::value_type value_type; |
| 4404 | typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4405 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), |
| 4406 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4407 | } |
| 4408 | |
| 4409 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4410 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4411 | typename enable_if |
| 4412 | < |
| 4413 | __is_val_expr<_Expr>::value, |
| 4414 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, |
| 4415 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4416 | >::type |
| 4417 | operator!=(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4418 | { |
| 4419 | typedef typename _Expr::value_type value_type; |
| 4420 | typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4421 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), |
| 4422 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4423 | } |
| 4424 | |
| 4425 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4426 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4427 | typename enable_if |
| 4428 | < |
| 4429 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4430 | __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4431 | >::type |
| 4432 | operator<(const _Expr1& __x, const _Expr2& __y) |
| 4433 | { |
| 4434 | typedef typename _Expr1::value_type value_type; |
| 4435 | typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op; |
| 4436 | return __val_expr<_Op>(_Op(less<value_type>(), __x, __y)); |
| 4437 | } |
| 4438 | |
| 4439 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4440 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4441 | typename enable_if |
| 4442 | < |
| 4443 | __is_val_expr<_Expr>::value, |
| 4444 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, |
| 4445 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4446 | >::type |
| 4447 | operator<(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4448 | { |
| 4449 | typedef typename _Expr::value_type value_type; |
| 4450 | typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4451 | return __val_expr<_Op>(_Op(less<value_type>(), |
| 4452 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4453 | } |
| 4454 | |
| 4455 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4456 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4457 | typename enable_if |
| 4458 | < |
| 4459 | __is_val_expr<_Expr>::value, |
| 4460 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, |
| 4461 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4462 | >::type |
| 4463 | operator<(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4464 | { |
| 4465 | typedef typename _Expr::value_type value_type; |
| 4466 | typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4467 | return __val_expr<_Op>(_Op(less<value_type>(), |
| 4468 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4469 | } |
| 4470 | |
| 4471 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4472 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4473 | typename enable_if |
| 4474 | < |
| 4475 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4476 | __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4477 | >::type |
| 4478 | operator>(const _Expr1& __x, const _Expr2& __y) |
| 4479 | { |
| 4480 | typedef typename _Expr1::value_type value_type; |
| 4481 | typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op; |
| 4482 | return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y)); |
| 4483 | } |
| 4484 | |
| 4485 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4486 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4487 | typename enable_if |
| 4488 | < |
| 4489 | __is_val_expr<_Expr>::value, |
| 4490 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, |
| 4491 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4492 | >::type |
| 4493 | operator>(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4494 | { |
| 4495 | typedef typename _Expr::value_type value_type; |
| 4496 | typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4497 | return __val_expr<_Op>(_Op(greater<value_type>(), |
| 4498 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4499 | } |
| 4500 | |
| 4501 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4502 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4503 | typename enable_if |
| 4504 | < |
| 4505 | __is_val_expr<_Expr>::value, |
| 4506 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, |
| 4507 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4508 | >::type |
| 4509 | operator>(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4510 | { |
| 4511 | typedef typename _Expr::value_type value_type; |
| 4512 | typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4513 | return __val_expr<_Op>(_Op(greater<value_type>(), |
| 4514 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4515 | } |
| 4516 | |
| 4517 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4518 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4519 | typename enable_if |
| 4520 | < |
| 4521 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4522 | __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4523 | >::type |
| 4524 | operator<=(const _Expr1& __x, const _Expr2& __y) |
| 4525 | { |
| 4526 | typedef typename _Expr1::value_type value_type; |
| 4527 | typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op; |
| 4528 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y)); |
| 4529 | } |
| 4530 | |
| 4531 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4532 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4533 | typename enable_if |
| 4534 | < |
| 4535 | __is_val_expr<_Expr>::value, |
| 4536 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, |
| 4537 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4538 | >::type |
| 4539 | operator<=(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4540 | { |
| 4541 | typedef typename _Expr::value_type value_type; |
| 4542 | typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4543 | return __val_expr<_Op>(_Op(less_equal<value_type>(), |
| 4544 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4545 | } |
| 4546 | |
| 4547 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4548 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4549 | typename enable_if |
| 4550 | < |
| 4551 | __is_val_expr<_Expr>::value, |
| 4552 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, |
| 4553 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4554 | >::type |
| 4555 | operator<=(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4556 | { |
| 4557 | typedef typename _Expr::value_type value_type; |
| 4558 | typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4559 | return __val_expr<_Op>(_Op(less_equal<value_type>(), |
| 4560 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4561 | } |
| 4562 | |
| 4563 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4564 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4565 | typename enable_if |
| 4566 | < |
| 4567 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4568 | __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4569 | >::type |
| 4570 | operator>=(const _Expr1& __x, const _Expr2& __y) |
| 4571 | { |
| 4572 | typedef typename _Expr1::value_type value_type; |
| 4573 | typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op; |
| 4574 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y)); |
| 4575 | } |
| 4576 | |
| 4577 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4578 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4579 | typename enable_if |
| 4580 | < |
| 4581 | __is_val_expr<_Expr>::value, |
| 4582 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, |
| 4583 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4584 | >::type |
| 4585 | operator>=(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4586 | { |
| 4587 | typedef typename _Expr::value_type value_type; |
| 4588 | typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4589 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), |
| 4590 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4591 | } |
| 4592 | |
| 4593 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4594 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4595 | typename enable_if |
| 4596 | < |
| 4597 | __is_val_expr<_Expr>::value, |
| 4598 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, |
| 4599 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4600 | >::type |
| 4601 | operator>=(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4602 | { |
| 4603 | typedef typename _Expr::value_type value_type; |
| 4604 | typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4605 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), |
| 4606 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4607 | } |
| 4608 | |
| 4609 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4610 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4611 | typename enable_if |
| 4612 | < |
| 4613 | __is_val_expr<_Expr>::value, |
| 4614 | __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > |
| 4615 | >::type |
| 4616 | abs(const _Expr& __x) |
| 4617 | { |
| 4618 | typedef typename _Expr::value_type value_type; |
| 4619 | typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op; |
| 4620 | return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x)); |
| 4621 | } |
| 4622 | |
| 4623 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4624 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4625 | typename enable_if |
| 4626 | < |
| 4627 | __is_val_expr<_Expr>::value, |
| 4628 | __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > |
| 4629 | >::type |
| 4630 | acos(const _Expr& __x) |
| 4631 | { |
| 4632 | typedef typename _Expr::value_type value_type; |
| 4633 | typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op; |
| 4634 | return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x)); |
| 4635 | } |
| 4636 | |
| 4637 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4638 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4639 | typename enable_if |
| 4640 | < |
| 4641 | __is_val_expr<_Expr>::value, |
| 4642 | __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > |
| 4643 | >::type |
| 4644 | asin(const _Expr& __x) |
| 4645 | { |
| 4646 | typedef typename _Expr::value_type value_type; |
| 4647 | typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op; |
| 4648 | return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x)); |
| 4649 | } |
| 4650 | |
| 4651 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4652 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4653 | typename enable_if |
| 4654 | < |
| 4655 | __is_val_expr<_Expr>::value, |
| 4656 | __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > |
| 4657 | >::type |
| 4658 | atan(const _Expr& __x) |
| 4659 | { |
| 4660 | typedef typename _Expr::value_type value_type; |
| 4661 | typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op; |
| 4662 | return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x)); |
| 4663 | } |
| 4664 | |
| 4665 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4666 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4667 | typename enable_if |
| 4668 | < |
| 4669 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4670 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4671 | >::type |
| 4672 | atan2(const _Expr1& __x, const _Expr2& __y) |
| 4673 | { |
| 4674 | typedef typename _Expr1::value_type value_type; |
| 4675 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op; |
| 4676 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); |
| 4677 | } |
| 4678 | |
| 4679 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4680 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4681 | typename enable_if |
| 4682 | < |
| 4683 | __is_val_expr<_Expr>::value, |
| 4684 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, |
| 4685 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4686 | >::type |
| 4687 | atan2(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4688 | { |
| 4689 | typedef typename _Expr::value_type value_type; |
| 4690 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4691 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), |
| 4692 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4693 | } |
| 4694 | |
| 4695 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4696 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4697 | typename enable_if |
| 4698 | < |
| 4699 | __is_val_expr<_Expr>::value, |
| 4700 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, |
| 4701 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4702 | >::type |
| 4703 | atan2(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4704 | { |
| 4705 | typedef typename _Expr::value_type value_type; |
| 4706 | typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4707 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), |
| 4708 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4709 | } |
| 4710 | |
| 4711 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4712 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4713 | typename enable_if |
| 4714 | < |
| 4715 | __is_val_expr<_Expr>::value, |
| 4716 | __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > |
| 4717 | >::type |
| 4718 | cos(const _Expr& __x) |
| 4719 | { |
| 4720 | typedef typename _Expr::value_type value_type; |
| 4721 | typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op; |
| 4722 | return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x)); |
| 4723 | } |
| 4724 | |
| 4725 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4726 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4727 | typename enable_if |
| 4728 | < |
| 4729 | __is_val_expr<_Expr>::value, |
| 4730 | __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > |
| 4731 | >::type |
| 4732 | cosh(const _Expr& __x) |
| 4733 | { |
| 4734 | typedef typename _Expr::value_type value_type; |
| 4735 | typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op; |
| 4736 | return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x)); |
| 4737 | } |
| 4738 | |
| 4739 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4740 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4741 | typename enable_if |
| 4742 | < |
| 4743 | __is_val_expr<_Expr>::value, |
| 4744 | __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > |
| 4745 | >::type |
| 4746 | exp(const _Expr& __x) |
| 4747 | { |
| 4748 | typedef typename _Expr::value_type value_type; |
| 4749 | typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op; |
| 4750 | return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x)); |
| 4751 | } |
| 4752 | |
| 4753 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4754 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4755 | typename enable_if |
| 4756 | < |
| 4757 | __is_val_expr<_Expr>::value, |
| 4758 | __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > |
| 4759 | >::type |
| 4760 | log(const _Expr& __x) |
| 4761 | { |
| 4762 | typedef typename _Expr::value_type value_type; |
| 4763 | typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op; |
| 4764 | return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x)); |
| 4765 | } |
| 4766 | |
| 4767 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4768 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4769 | typename enable_if |
| 4770 | < |
| 4771 | __is_val_expr<_Expr>::value, |
| 4772 | __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > |
| 4773 | >::type |
| 4774 | log10(const _Expr& __x) |
| 4775 | { |
| 4776 | typedef typename _Expr::value_type value_type; |
| 4777 | typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op; |
| 4778 | return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x)); |
| 4779 | } |
| 4780 | |
| 4781 | template<class _Expr1, class _Expr2> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4782 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4783 | typename enable_if |
| 4784 | < |
| 4785 | __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, |
| 4786 | __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 4787 | >::type |
| 4788 | pow(const _Expr1& __x, const _Expr2& __y) |
| 4789 | { |
| 4790 | typedef typename _Expr1::value_type value_type; |
| 4791 | typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op; |
| 4792 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); |
| 4793 | } |
| 4794 | |
| 4795 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4796 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4797 | typename enable_if |
| 4798 | < |
| 4799 | __is_val_expr<_Expr>::value, |
| 4800 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, |
| 4801 | _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 4802 | >::type |
| 4803 | pow(const _Expr& __x, const typename _Expr::value_type& __y) |
| 4804 | { |
| 4805 | typedef typename _Expr::value_type value_type; |
| 4806 | typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
| 4807 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), |
| 4808 | __x, __scalar_expr<value_type>(__y, __x.size()))); |
| 4809 | } |
| 4810 | |
| 4811 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4812 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4813 | typename enable_if |
| 4814 | < |
| 4815 | __is_val_expr<_Expr>::value, |
| 4816 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, |
| 4817 | __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 4818 | >::type |
| 4819 | pow(const typename _Expr::value_type& __x, const _Expr& __y) |
| 4820 | { |
| 4821 | typedef typename _Expr::value_type value_type; |
| 4822 | typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
| 4823 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), |
| 4824 | __scalar_expr<value_type>(__x, __y.size()), __y)); |
| 4825 | } |
| 4826 | |
| 4827 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4828 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4829 | typename enable_if |
| 4830 | < |
| 4831 | __is_val_expr<_Expr>::value, |
| 4832 | __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > |
| 4833 | >::type |
| 4834 | sin(const _Expr& __x) |
| 4835 | { |
| 4836 | typedef typename _Expr::value_type value_type; |
| 4837 | typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op; |
| 4838 | return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x)); |
| 4839 | } |
| 4840 | |
| 4841 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4842 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4843 | typename enable_if |
| 4844 | < |
| 4845 | __is_val_expr<_Expr>::value, |
| 4846 | __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > |
| 4847 | >::type |
| 4848 | sinh(const _Expr& __x) |
| 4849 | { |
| 4850 | typedef typename _Expr::value_type value_type; |
| 4851 | typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op; |
| 4852 | return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x)); |
| 4853 | } |
| 4854 | |
| 4855 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4856 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4857 | typename enable_if |
| 4858 | < |
| 4859 | __is_val_expr<_Expr>::value, |
| 4860 | __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > |
| 4861 | >::type |
| 4862 | sqrt(const _Expr& __x) |
| 4863 | { |
| 4864 | typedef typename _Expr::value_type value_type; |
| 4865 | typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op; |
| 4866 | return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x)); |
| 4867 | } |
| 4868 | |
| 4869 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4870 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4871 | typename enable_if |
| 4872 | < |
| 4873 | __is_val_expr<_Expr>::value, |
| 4874 | __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > |
| 4875 | >::type |
| 4876 | tan(const _Expr& __x) |
| 4877 | { |
| 4878 | typedef typename _Expr::value_type value_type; |
| 4879 | typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op; |
| 4880 | return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x)); |
| 4881 | } |
| 4882 | |
| 4883 | template<class _Expr> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4884 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4885 | typename enable_if |
| 4886 | < |
| 4887 | __is_val_expr<_Expr>::value, |
| 4888 | __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > |
| 4889 | >::type |
| 4890 | tanh(const _Expr& __x) |
| 4891 | { |
| 4892 | typedef typename _Expr::value_type value_type; |
| 4893 | typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op; |
| 4894 | return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x)); |
| 4895 | } |
| 4896 | |
| 4897 | template <class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4898 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4899 | _Tp* |
| 4900 | begin(valarray<_Tp>& __v) |
| 4901 | { |
| 4902 | return __v.__begin_; |
| 4903 | } |
| 4904 | |
| 4905 | template <class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4906 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4907 | const _Tp* |
| 4908 | begin(const valarray<_Tp>& __v) |
| 4909 | { |
| 4910 | return __v.__begin_; |
| 4911 | } |
| 4912 | |
| 4913 | template <class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4914 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4915 | _Tp* |
| 4916 | end(valarray<_Tp>& __v) |
| 4917 | { |
| 4918 | return __v.__end_; |
| 4919 | } |
| 4920 | |
| 4921 | template <class _Tp> |
Howard Hinnant | 1c265cd | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 4922 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4923 | const _Tp* |
| 4924 | end(const valarray<_Tp>& __v) |
| 4925 | { |
| 4926 | return __v.__end_; |
| 4927 | } |
| 4928 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4929 | _LIBCPP_END_NAMESPACE_STD |
| 4930 | |
Eric Fiselier | f4433a3 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 4931 | _LIBCPP_POP_MACROS |
| 4932 | |
Mark de Wever | ee5fe27 | 2022-09-02 17:53:28 +0200 | [diff] [blame] | 4933 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 4934 | # include <algorithm> |
Nikolas Klauser | 1e4ae5d | 2022-11-02 20:27:42 +0100 | [diff] [blame] | 4935 | # include <concepts> |
Mark de Wever | ee5fe27 | 2022-09-02 17:53:28 +0200 | [diff] [blame] | 4936 | # include <functional> |
| 4937 | #endif |
| 4938 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 4939 | #endif // _LIBCPP_VALARRAY |