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