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