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