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