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