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