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