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