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